Skip to content

fix($compile): fix IE11 adjacent text nodes issue #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: v1.2.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,10 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
}
}

function isTextNode(node) {
return node && node.nodeType === Node.TEXT_NODE;
}

/**
* Compile function matches each node in nodeList against the directives. Once all directives
* for a particular node are collected their compile functions are executed. The compile
Expand All @@ -915,7 +919,18 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
var linkFns = [],
attrs, directives, nodeLinkFn, childNodes, childLinkFn, linkFnFound;

var child;

for (var i = 0; i < nodeList.length; i++) {
child = nodeList[i];
if (isTextNode(child)) {
while (isTextNode(child.nextSibling) && child.nextSibling.nodeValue) {
nodeList[i].nodeValue += child.nextSibling.nodeValue;
child.nextSibling.nodeValue = '';
child = child.nextSibling;
}
}

attrs = new Attributes();

// we must always refer to nodeList[i] since the nodes can be replaced underneath us.
Expand Down