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

Commit 81b7e5a

Browse files
IgorMinarrodyhaddad
authored andcommittedJun 13, 2014
perf($compile): move ng-binding class stamping for interpolation into compile phase
1 parent 1b18902 commit 81b7e5a

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed
 

‎src/ng/compile.js

+24-16
Original file line numberDiff line numberDiff line change
@@ -1809,23 +1809,31 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
18091809
}
18101810

18111811

1812-
function addTextInterpolateDirective(directives, text) {
1813-
var interpolateFn = $interpolate(text, true);
1814-
if (interpolateFn) {
1815-
directives.push({
1816-
priority: 0,
1817-
compile: valueFn(function textInterpolateLinkFn(scope, node) {
1818-
var parent = node.parent(),
1819-
bindings = parent.data('$binding') || [];
1820-
bindings.push(interpolateFn);
1821-
safeAddClass(parent.data('$binding', bindings), 'ng-binding');
1822-
scope.$watch(interpolateFn, function interpolateFnWatchAction(value) {
1823-
node[0].nodeValue = value;
1824-
});
1825-
})
1826-
});
1812+
function addTextInterpolateDirective(directives, text) {
1813+
var interpolateFn = $interpolate(text, true);
1814+
if (interpolateFn) {
1815+
directives.push({
1816+
priority: 0,
1817+
compile: function textInterpolateCompileFn(templateNode) {
1818+
// when transcluding a template that has bindings in the root
1819+
// then we don't have a parent and should do this in the linkFn
1820+
var parent = templateNode.parent(), hasCompileParent = parent.length;
1821+
if (hasCompileParent) safeAddClass(templateNode.parent(), 'ng-binding');
1822+
1823+
return function textInterpolateLinkFn(scope, node) {
1824+
var parent = node.parent(),
1825+
bindings = parent.data('$binding') || [];
1826+
bindings.push(interpolateFn);
1827+
parent.data('$binding', bindings);
1828+
if (!hasCompileParent) safeAddClass(parent, 'ng-binding');
1829+
scope.$watch(interpolateFn, function interpolateFnWatchAction(value) {
1830+
node[0].nodeValue = value;
1831+
});
1832+
};
1833+
}
1834+
});
1835+
}
18271836
}
1828-
}
18291837

18301838

18311839
function getTrustedContext(node, attrNormalizedName) {

0 commit comments

Comments
 (0)
This repository has been archived.