mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-14 22:39:32 +08:00
perf($compile): move ng-binding class stamping for interpolation into compile phase
This commit is contained in:
@@ -1847,18 +1847,26 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
if (interpolateFn) {
|
||||
directives.push({
|
||||
priority: 0,
|
||||
compile: valueFn(function textInterpolateLinkFn(scope, node) {
|
||||
var parent = node.parent(),
|
||||
bindings = parent.data('$binding') || [];
|
||||
// Need to interpolate again in case this is using one-time bindings in multiple clones
|
||||
// of transcluded templates.
|
||||
interpolateFn = $interpolate(text);
|
||||
bindings.push(interpolateFn);
|
||||
safeAddClass(parent.data('$binding', bindings), 'ng-binding');
|
||||
scope.$watch(interpolateFn, function interpolateFnWatchAction(value) {
|
||||
node[0].nodeValue = value;
|
||||
});
|
||||
})
|
||||
compile: function textInterpolateCompileFn(templateNode) {
|
||||
// when transcluding a template that has bindings in the root
|
||||
// then we don't have a parent and should do this in the linkFn
|
||||
var parent = templateNode.parent(), hasCompileParent = parent.length;
|
||||
if (hasCompileParent) safeAddClass(templateNode.parent(), 'ng-binding');
|
||||
|
||||
return function textInterpolateLinkFn(scope, node) {
|
||||
var parent = node.parent(),
|
||||
bindings = parent.data('$binding') || [];
|
||||
// Need to interpolate again in case this is using one-time bindings in multiple clones
|
||||
// of transcluded templates.
|
||||
interpolateFn = $interpolate(text);
|
||||
bindings.push(interpolateFn);
|
||||
parent.data('$binding', bindings);
|
||||
if (!hasCompileParent) safeAddClass(parent, 'ng-binding');
|
||||
scope.$watch(interpolateFn, function interpolateFnWatchAction(value) {
|
||||
node[0].nodeValue = value;
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user