Skip to content

Commit 6e6f319

Browse files
refactor($compile): rename variables to clarify their purpose
Closes angular#12528
1 parent 66fee7e commit 6e6f319

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

src/ng/compile.js

+16-17
Original file line numberDiff line numberDiff line change
@@ -2021,7 +2021,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
20212021

20222022
function nodeLinkFn(childLinkFn, scope, linkNode, $rootElement, boundTranscludeFn) {
20232023
var i, ii, linkFn, controller, isolateScope, elementControllers, transcludeFn, $element,
2024-
attrs;
2024+
attrs, removeScopeBindingWatches, removeControllerBindingWatches;
20252025

20262026
if (compileNode === linkNode) {
20272027
attrs = templateAttrs;
@@ -2053,26 +2053,25 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
20532053
compile.$$addScopeClass($element, true);
20542054
isolateScope.$$isolateBindings =
20552055
newIsolateScopeDirective.$$isolateBindings;
2056-
var parentWatchDestroyer = initializeDirectiveBindings(scope, attrs, isolateScope,
2056+
removeScopeBindingWatches = initializeDirectiveBindings(scope, attrs, isolateScope,
20572057
isolateScope.$$isolateBindings,
20582058
newIsolateScopeDirective);
2059-
if (parentWatchDestroyer) {
2060-
isolateScope.$on('$destroy', parentWatchDestroyer);
2059+
if (removeScopeBindingWatches) {
2060+
isolateScope.$on('$destroy', removeScopeBindingWatches);
20612061
}
20622062
}
20632063
if (elementControllers) {
20642064
// Initialize bindToController bindings for new/isolate scopes
20652065
var scopeDirective = newIsolateScopeDirective || newScopeDirective;
20662066
var bindings;
20672067
var controllerForBindings;
2068-
var destroyBindings;
20692068
if (scopeDirective && elementControllers[scopeDirective.name]) {
20702069
bindings = scopeDirective.$$bindings.bindToController;
20712070
controller = elementControllers[scopeDirective.name];
20722071

20732072
if (controller && controller.identifier && bindings) {
20742073
controllerForBindings = controller;
2075-
destroyBindings =
2074+
removeControllerBindingWatches =
20762075
initializeDirectiveBindings(scope, attrs, controller.instance,
20772076
bindings, scopeDirective) || noop;
20782077
}
@@ -2088,8 +2087,8 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
20882087
$element.data('$' + i + 'Controller', controllerResult);
20892088
if (controller === controllerForBindings) {
20902089
// Remove and re-install bindToController bindings
2091-
destroyBindings();
2092-
destroyBindings =
2090+
removeControllerBindingWatches();
2091+
removeControllerBindingWatches =
20932092
initializeDirectiveBindings(scope, attrs, controllerResult, bindings, scopeDirective);
20942093
}
20952094
}
@@ -2629,7 +2628,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
26292628
// Set up $watches for isolate scope and controller bindings. This process
26302629
// only occurs for isolate scopes and new scopes with controllerAs.
26312630
function initializeDirectiveBindings(scope, attrs, destination, bindings, directive) {
2632-
var onNewScopeDestroyed;
2631+
var removeWatchCollection;
26332632
forEach(bindings, function(definition, scopeName) {
26342633
var attrName = definition.attrName,
26352634
optional = definition.optional,
@@ -2691,14 +2690,14 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
26912690
return lastValue = parentValue;
26922691
};
26932692
parentValueWatch.$stateful = true;
2694-
var unwatch;
2693+
var removeWatch;
26952694
if (definition.collection) {
2696-
unwatch = scope.$watchCollection(attrs[attrName], parentValueWatch);
2695+
removeWatch = scope.$watchCollection(attrs[attrName], parentValueWatch);
26972696
} else {
2698-
unwatch = scope.$watch($parse(attrs[attrName], parentValueWatch), null, parentGet.literal);
2697+
removeWatch = scope.$watch($parse(attrs[attrName], parentValueWatch), null, parentGet.literal);
26992698
}
2700-
onNewScopeDestroyed = (onNewScopeDestroyed || []);
2701-
onNewScopeDestroyed.push(unwatch);
2699+
removeWatchCollection = (removeWatchCollection || []);
2700+
removeWatchCollection.push(removeWatch);
27022701
break;
27032702

27042703
case '&':
@@ -2715,9 +2714,9 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
27152714
}
27162715
});
27172716

2718-
return onNewScopeDestroyed && function destroyBindings() {
2719-
for (var i = 0, ii = onNewScopeDestroyed.length; i < ii; ++i) {
2720-
onNewScopeDestroyed[i]();
2717+
return removeWatchCollection && function removeWatches() {
2718+
for (var i = 0, ii = removeWatchCollection.length; i < ii; ++i) {
2719+
removeWatchCollection[i]();
27212720
}
27222721
};
27232722
}

0 commit comments

Comments
 (0)