Skip to content

Commit e11a7a0

Browse files
committed
fix($compile): workaround for IE11 MutationObserver
IE11 MutationObserver breaks consecutive text nodes into several text nodes. This patch merges consecutive text nodes into a single node before looking for interpolations. Closes angular#11781
1 parent 1268b17 commit e11a7a0

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/ng/compile.js

+5
Original file line numberDiff line numberDiff line change
@@ -1540,6 +1540,11 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
15401540
}
15411541
break;
15421542
case NODE_TYPE_TEXT: /* Text Node */
1543+
// Workaround for IE11 #11781
1544+
while (node.parentNode && node.nextSibling && node.nextSibling.nodeType === NODE_TYPE_TEXT) {
1545+
node.nodeValue = node.nodeValue + node.nextSibling.nodeValue;
1546+
node.parentNode.removeChild(node.nextSibling);
1547+
}
15431548
addTextInterpolateDirective(directives, node.nodeValue);
15441549
break;
15451550
case NODE_TYPE_COMMENT: /* Comment */

test/ng/compileSpec.js

+10
Original file line numberDiff line numberDiff line change
@@ -2762,6 +2762,16 @@ describe('$compile', function() {
27622762
}));
27632763

27642764

2765+
it('should handle consecutive text elements as a single text element', inject(function($rootScope, $compile) {
2766+
var base = jqLite('<div></div>');
2767+
base[0].appendChild(document.createTextNode('Lucas {{1+'));
2768+
base[0].appendChild(document.createTextNode('2}} Lucas'));
2769+
element = $compile(base)($rootScope);
2770+
$rootScope.$digest();
2771+
expect(element.text()).toBe('Lucas 3 Lucas');
2772+
}));
2773+
2774+
27652775
it('should support custom start/end interpolation symbols in template and directive template',
27662776
function() {
27672777
module(function($interpolateProvider, $compileProvider) {

0 commit comments

Comments
 (0)