This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
compile: when terminal=true mutation of tElement during compile breaks interpolation of following TextNode #9198
Open
Description
Example
http://plnkr.co/edit/SgQ98ET9j7lUHTliEVoA?p=preview
/*
scenario:
using tElement.detach() in compile of a directive with terminal=true:
result:
compile does not interpolate first (only) following TextNode of the element
directive:
*/
directive('terminalDirective', function(){
return {
terminal:true,
compile: function(tElement){
tElement.detach();
// some other logic
}
}
})
<h5>Disables interpolation of following adjacent TextNodes</h5>
<ul>
<li ng-repeat="i in [1]">
<terminal-directive>Element:{{ i }}</terminal-directive>
TextNode: {{ i }}
</li>
</ul>
<h5>Preceding textNodes are interpolated correclty</h5>
<ul>
<li ng-repeat="i in [1]">
TextNode:{{ i }}
<terminal-directive>Element:{{ i }}</terminal-directive>
</li>
</ul>
<h5>Subsequent Elements are interpolated correclty, but not textNodes</h5>
<ul>
<li ng-repeat="i in [1]">
TextNode:{{ i }}
<terminal-directive>Element:{{ i }}</terminal-directive>
TextNode:{{ i }}
<div>Element:{{ i }}</div>
TextNode:{{ i }}
<div>Element:{{ i }}</div>
TextNode:{{ i }}
</li>
</ul>
Possible cause: node index mismatch.
In some places compile creates a copy of childNodes so any kind of mutation does not cause the index to be out of sync.
https://github.com/angular/angular.js/blob/master/src/ng/compile.js#L1116