@@ -1967,7 +1967,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
1967
1967
1968
1968
function nodeLinkFn ( childLinkFn , scope , linkNode , $rootElement , boundTranscludeFn ) {
1969
1969
var i , ii , linkFn , controller , isolateScope , elementControllers , transcludeFn , $element ,
1970
- attrs ;
1970
+ attrs , removeScopeBindingWatches , removeControllerBindingWatches ;
1971
1971
1972
1972
if ( compileNode === linkNode ) {
1973
1973
attrs = templateAttrs ;
@@ -1999,26 +1999,25 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
1999
1999
compile . $$addScopeClass ( $element , true ) ;
2000
2000
isolateScope . $$isolateBindings =
2001
2001
newIsolateScopeDirective . $$isolateBindings ;
2002
- var parentWatchDestroyer = initializeDirectiveBindings ( scope , attrs , isolateScope ,
2002
+ removeScopeBindingWatches = initializeDirectiveBindings ( scope , attrs , isolateScope ,
2003
2003
isolateScope . $$isolateBindings ,
2004
2004
newIsolateScopeDirective ) ;
2005
- if ( parentWatchDestroyer ) {
2006
- isolateScope . $on ( '$destroy' , parentWatchDestroyer ) ;
2005
+ if ( removeScopeBindingWatches ) {
2006
+ isolateScope . $on ( '$destroy' , removeScopeBindingWatches ) ;
2007
2007
}
2008
2008
}
2009
2009
if ( elementControllers ) {
2010
2010
// Initialize bindToController bindings for new/isolate scopes
2011
2011
var scopeDirective = newIsolateScopeDirective || newScopeDirective ;
2012
2012
var bindings ;
2013
2013
var controllerForBindings ;
2014
- var destroyBindings ;
2015
2014
if ( scopeDirective && elementControllers [ scopeDirective . name ] ) {
2016
2015
bindings = scopeDirective . $$bindings . bindToController ;
2017
2016
controller = elementControllers [ scopeDirective . name ] ;
2018
2017
2019
2018
if ( controller && controller . identifier && bindings ) {
2020
2019
controllerForBindings = controller ;
2021
- destroyBindings =
2020
+ removeControllerBindingWatches =
2022
2021
initializeDirectiveBindings ( scope , attrs , controller . instance ,
2023
2022
bindings , scopeDirective ) || noop ;
2024
2023
}
@@ -2034,8 +2033,8 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
2034
2033
$element . data ( '$' + i + 'Controller' , controllerResult ) ;
2035
2034
if ( controller === controllerForBindings ) {
2036
2035
// Remove and re-install bindToController bindings
2037
- destroyBindings ( ) ;
2038
- destroyBindings =
2036
+ removeControllerBindingWatches ( ) ;
2037
+ removeControllerBindingWatches =
2039
2038
initializeDirectiveBindings ( scope , attrs , controllerResult , bindings , scopeDirective ) ;
2040
2039
}
2041
2040
}
@@ -2575,7 +2574,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
2575
2574
// Set up $watches for isolate scope and controller bindings. This process
2576
2575
// only occurs for isolate scopes and new scopes with controllerAs.
2577
2576
function initializeDirectiveBindings ( scope , attrs , destination , bindings , directive ) {
2578
- var onNewScopeDestroyed ;
2577
+ var removeWatchCollection ;
2579
2578
forEach ( bindings , function ( definition , scopeName ) {
2580
2579
var attrName = definition . attrName ,
2581
2580
optional = definition . optional ,
@@ -2637,14 +2636,14 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
2637
2636
return lastValue = parentValue ;
2638
2637
} ;
2639
2638
parentValueWatch . $stateful = true ;
2640
- var unwatch ;
2639
+ var removeWatch ;
2641
2640
if ( definition . collection ) {
2642
- unwatch = scope . $watchCollection ( attrs [ attrName ] , parentValueWatch ) ;
2641
+ removeWatch = scope . $watchCollection ( attrs [ attrName ] , parentValueWatch ) ;
2643
2642
} else {
2644
- unwatch = scope . $watch ( $parse ( attrs [ attrName ] , parentValueWatch ) , null , parentGet . literal ) ;
2643
+ removeWatch = scope . $watch ( $parse ( attrs [ attrName ] , parentValueWatch ) , null , parentGet . literal ) ;
2645
2644
}
2646
- onNewScopeDestroyed = ( onNewScopeDestroyed || [ ] ) ;
2647
- onNewScopeDestroyed . push ( unwatch ) ;
2645
+ removeWatchCollection = ( removeWatchCollection || [ ] ) ;
2646
+ removeWatchCollection . push ( removeWatch ) ;
2648
2647
break ;
2649
2648
2650
2649
case '&' :
@@ -2661,9 +2660,9 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
2661
2660
}
2662
2661
} ) ;
2663
2662
2664
- return onNewScopeDestroyed && function destroyBindings ( ) {
2665
- for ( var i = 0 , ii = onNewScopeDestroyed . length ; i < ii ; ++ i ) {
2666
- onNewScopeDestroyed [ i ] ( ) ;
2663
+ return removeWatchCollection && function removeWatches ( ) {
2664
+ for ( var i = 0 , ii = removeWatchCollection . length ; i < ii ; ++ i ) {
2665
+ removeWatchCollection [ i ] ( ) ;
2667
2666
}
2668
2667
} ;
2669
2668
}
0 commit comments