mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Removed more IE workarounds from knockoutjs
This commit is contained in:
parent
9241726ffe
commit
118c1613a4
12 changed files with 160 additions and 455 deletions
44
vendors/knockout/src/virtualElements.js
vendored
44
vendors/knockout/src/virtualElements.js
vendored
|
|
@ -7,21 +7,16 @@
|
|||
// The point of all this is to support containerless templates (e.g., <!-- ko foreach:someCollection -->blah<!-- /ko -->)
|
||||
// without having to scatter special cases all over the binding and templating code.
|
||||
|
||||
// IE 9 cannot reliably read the "nodeValue" property of a comment node (see https://github.com/SteveSanderson/knockout/issues/186)
|
||||
// but it does give them a nonstandard alternative property called "text" that it can read reliably. Other browsers don't have that property.
|
||||
// So, use node.text where available, and node.nodeValue elsewhere
|
||||
var commentNodesHaveTextProperty = document && document.createComment("test").text === "<!--test-->";
|
||||
|
||||
var startCommentRegex = commentNodesHaveTextProperty ? /^<!--\s*ko(?:\s+([\s\S]+))?\s*-->$/ : /^\s*ko(?:\s+([\s\S]+))?\s*$/;
|
||||
var endCommentRegex = commentNodesHaveTextProperty ? /^<!--\s*\/ko\s*-->$/ : /^\s*\/ko\s*$/;
|
||||
var startCommentRegex = /^\s*ko(?:\s+([\s\S]+))?\s*$/;
|
||||
var endCommentRegex = /^\s*\/ko\s*$/;
|
||||
var htmlTagsWithOptionallyClosingChildren = { 'ul': true, 'ol': true };
|
||||
|
||||
function isStartComment(node) {
|
||||
return (node.nodeType == 8) && startCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);
|
||||
return (node.nodeType == 8) && startCommentRegex.test(node.nodeValue);
|
||||
}
|
||||
|
||||
function isEndComment(node) {
|
||||
return (node.nodeType == 8) && endCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);
|
||||
return (node.nodeType == 8) && endCommentRegex.test(node.nodeValue);
|
||||
}
|
||||
|
||||
function isUnmatchedEndComment(node) {
|
||||
|
|
@ -181,37 +176,8 @@
|
|||
hasBindingValue: isStartComment,
|
||||
|
||||
virtualNodeBindingValue: function(node) {
|
||||
var regexMatch = (commentNodesHaveTextProperty ? node.text : node.nodeValue).match(startCommentRegex);
|
||||
var regexMatch = (node.nodeValue).match(startCommentRegex);
|
||||
return regexMatch ? regexMatch[1] : null;
|
||||
},
|
||||
|
||||
normaliseVirtualElementDomStructure: function(elementVerified) {
|
||||
// Workaround for https://github.com/SteveSanderson/knockout/issues/155
|
||||
// (IE <= 8 or IE 9 quirks mode parses your HTML weirdly, treating closing </li> tags as if they don't exist, thereby moving comment nodes
|
||||
// that are direct descendants of <ul> into the preceding <li>)
|
||||
if (!htmlTagsWithOptionallyClosingChildren[ko.utils.tagNameLower(elementVerified)])
|
||||
return;
|
||||
|
||||
// Scan immediate children to see if they contain unbalanced comment tags. If they do, those comment tags
|
||||
// must be intended to appear *after* that child, so move them there.
|
||||
var childNode = elementVerified.firstChild;
|
||||
if (childNode) {
|
||||
do {
|
||||
if (childNode.nodeType === 1) {
|
||||
var unbalancedTags = getUnbalancedChildTags(childNode);
|
||||
if (unbalancedTags) {
|
||||
// Fix up the DOM by moving the unbalanced tags to where they most likely were intended to be placed - *after* the child
|
||||
var nodeToInsertBefore = childNode.nextSibling;
|
||||
for (var i = 0; i < unbalancedTags.length; i++) {
|
||||
if (nodeToInsertBefore)
|
||||
elementVerified.insertBefore(unbalancedTags[i], nodeToInsertBefore);
|
||||
else
|
||||
elementVerified.append(unbalancedTags[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (childNode = childNode.nextSibling);
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue