Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 77172ac

Browse files
committed
fixup! fix($compile): correctly merge consecutive text nodes on IE11
1 parent 1c9cabf commit 77172ac

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

src/ng/compile.js

+29-21
Original file line numberDiff line numberDiff line change
@@ -1845,33 +1845,15 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
18451845
// `nodeList` can be either an element's `.childNodes` (live NodeList)
18461846
// or a jqLite/jQuery collection or an array
18471847
notLiveList = isArray(nodeList) || (nodeList instanceof jqLite),
1848-
attrs, directives, node, nodeLinkFn, childNodes, childLinkFn, linkFnFound, nodeLinkFnFound;
1848+
attrs, directives, nodeLinkFn, childNodes, childLinkFn, linkFnFound, nodeLinkFnFound;
18491849

18501850

18511851
for (var i = 0; i < nodeList.length; i++) {
18521852
attrs = new Attributes();
1853-
node = nodeList[i];
18541853

18551854
// Workaround for #11781 and #14924
1856-
if ((msie === 11) && (node.nodeType === NODE_TYPE_TEXT)) {
1857-
var parent = node.parentNode;
1858-
var sibling;
1859-
1860-
while (true) {
1861-
sibling = parent ? node.nextSibling : nodeList[i + 1];
1862-
if (!sibling || sibling.nodeType !== NODE_TYPE_TEXT) {
1863-
break;
1864-
}
1865-
1866-
node.nodeValue = node.nodeValue + sibling.nodeValue;
1867-
1868-
if (sibling.parentNode) {
1869-
sibling.parentNode.removeChild(sibling);
1870-
}
1871-
if (notLiveList && sibling === nodeList[i + 1]) {
1872-
nodeList.splice(i + 1, 1);
1873-
}
1874-
}
1855+
if (msie === 11) {
1856+
mergeConsecutiveTextNodes(nodeList, i, notLiveList);
18751857
}
18761858

18771859
// We must always refer to `nodeList[i]` hereafter,
@@ -1966,6 +1948,32 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
19661948
}
19671949
}
19681950

1951+
function mergeConsecutiveTextNodes(nodeList, idx, notLiveList) {
1952+
var node = nodeList[idx];
1953+
var parent = node.parentNode;
1954+
var sibling;
1955+
1956+
if (node.nodeType !== NODE_TYPE_TEXT) {
1957+
return;
1958+
}
1959+
1960+
while (true) {
1961+
sibling = parent ? node.nextSibling : nodeList[idx + 1];
1962+
if (!sibling || sibling.nodeType !== NODE_TYPE_TEXT) {
1963+
break;
1964+
}
1965+
1966+
node.nodeValue = node.nodeValue + sibling.nodeValue;
1967+
1968+
if (sibling.parentNode) {
1969+
sibling.parentNode.removeChild(sibling);
1970+
}
1971+
if (notLiveList && sibling === nodeList[idx + 1]) {
1972+
nodeList.splice(idx + 1, 1);
1973+
}
1974+
}
1975+
}
1976+
19691977
function createBoundTranscludeFn(scope, transcludeFn, previousBoundTranscludeFn) {
19701978
function boundTranscludeFn(transcludedScope, cloneFn, controllers, futureParentElement, containingScope) {
19711979

0 commit comments

Comments
 (0)