@@ -2021,7 +2021,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
2021
2021
2022
2022
function nodeLinkFn ( childLinkFn , scope , linkNode , $rootElement , boundTranscludeFn ) {
2023
2023
var i , ii , linkFn , controller , isolateScope , elementControllers , transcludeFn , $element ,
2024
- attrs ;
2024
+ attrs , removeScopeBindingWatches , removeControllerBindingWatches ;
2025
2025
2026
2026
if ( compileNode === linkNode ) {
2027
2027
attrs = templateAttrs ;
@@ -2053,26 +2053,25 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
2053
2053
compile . $$addScopeClass ( $element , true ) ;
2054
2054
isolateScope . $$isolateBindings =
2055
2055
newIsolateScopeDirective . $$isolateBindings ;
2056
- var parentWatchDestroyer = initializeDirectiveBindings ( scope , attrs , isolateScope ,
2056
+ removeScopeBindingWatches = initializeDirectiveBindings ( scope , attrs , isolateScope ,
2057
2057
isolateScope . $$isolateBindings ,
2058
2058
newIsolateScopeDirective ) ;
2059
- if ( parentWatchDestroyer ) {
2060
- isolateScope . $on ( '$destroy' , parentWatchDestroyer ) ;
2059
+ if ( removeScopeBindingWatches ) {
2060
+ isolateScope . $on ( '$destroy' , removeScopeBindingWatches ) ;
2061
2061
}
2062
2062
}
2063
2063
if ( elementControllers ) {
2064
2064
// Initialize bindToController bindings for new/isolate scopes
2065
2065
var scopeDirective = newIsolateScopeDirective || newScopeDirective ;
2066
2066
var bindings ;
2067
2067
var controllerForBindings ;
2068
- var destroyBindings ;
2069
2068
if ( scopeDirective && elementControllers [ scopeDirective . name ] ) {
2070
2069
bindings = scopeDirective . $$bindings . bindToController ;
2071
2070
controller = elementControllers [ scopeDirective . name ] ;
2072
2071
2073
2072
if ( controller && controller . identifier && bindings ) {
2074
2073
controllerForBindings = controller ;
2075
- destroyBindings =
2074
+ removeControllerBindingWatches =
2076
2075
initializeDirectiveBindings ( scope , attrs , controller . instance ,
2077
2076
bindings , scopeDirective ) || noop ;
2078
2077
}
@@ -2088,8 +2087,8 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
2088
2087
$element . data ( '$' + i + 'Controller' , controllerResult ) ;
2089
2088
if ( controller === controllerForBindings ) {
2090
2089
// Remove and re-install bindToController bindings
2091
- destroyBindings ( ) ;
2092
- destroyBindings =
2090
+ removeControllerBindingWatches ( ) ;
2091
+ removeControllerBindingWatches =
2093
2092
initializeDirectiveBindings ( scope , attrs , controllerResult , bindings , scopeDirective ) ;
2094
2093
}
2095
2094
}
@@ -2629,7 +2628,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
2629
2628
// Set up $watches for isolate scope and controller bindings. This process
2630
2629
// only occurs for isolate scopes and new scopes with controllerAs.
2631
2630
function initializeDirectiveBindings ( scope , attrs , destination , bindings , directive ) {
2632
- var onNewScopeDestroyed ;
2631
+ var removeWatchCollection ;
2633
2632
forEach ( bindings , function ( definition , scopeName ) {
2634
2633
var attrName = definition . attrName ,
2635
2634
optional = definition . optional ,
@@ -2691,14 +2690,14 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
2691
2690
return lastValue = parentValue ;
2692
2691
} ;
2693
2692
parentValueWatch . $stateful = true ;
2694
- var unwatch ;
2693
+ var removeWatch ;
2695
2694
if ( definition . collection ) {
2696
- unwatch = scope . $watchCollection ( attrs [ attrName ] , parentValueWatch ) ;
2695
+ removeWatch = scope . $watchCollection ( attrs [ attrName ] , parentValueWatch ) ;
2697
2696
} else {
2698
- unwatch = scope . $watch ( $parse ( attrs [ attrName ] , parentValueWatch ) , null , parentGet . literal ) ;
2697
+ removeWatch = scope . $watch ( $parse ( attrs [ attrName ] , parentValueWatch ) , null , parentGet . literal ) ;
2699
2698
}
2700
- onNewScopeDestroyed = ( onNewScopeDestroyed || [ ] ) ;
2701
- onNewScopeDestroyed . push ( unwatch ) ;
2699
+ removeWatchCollection = ( removeWatchCollection || [ ] ) ;
2700
+ removeWatchCollection . push ( removeWatch ) ;
2702
2701
break ;
2703
2702
2704
2703
case '&' :
@@ -2715,9 +2714,9 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
2715
2714
}
2716
2715
} ) ;
2717
2716
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 ] ( ) ;
2721
2720
}
2722
2721
} ;
2723
2722
}
0 commit comments