This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +11
-6
lines changed
2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -1027,11 +1027,7 @@ function $ParseProvider() {
1027
1027
cache [ exp ] = parsedExpression ;
1028
1028
}
1029
1029
1030
- if ( parsedExpression . constant ) {
1031
- parsedExpression . $$unwatch = true ;
1032
- }
1033
-
1034
- return oneTime ? oneTimeWrapper ( parsedExpression ) : parsedExpression ;
1030
+ return oneTime || parsedExpression . constant ? oneTimeWrapper ( parsedExpression ) : parsedExpression ;
1035
1031
1036
1032
case 'function' :
1037
1033
return exp ;
@@ -1050,7 +1046,7 @@ function $ParseProvider() {
1050
1046
1051
1047
function oneTimeParseFn ( self , locals ) {
1052
1048
if ( ! stable ) {
1053
- lastValue = expression ( self , locals ) ;
1049
+ lastValue = expression . constant && lastValue ? lastValue : expression ( self , locals ) ;
1054
1050
oneTimeParseFn . $$unwatch = isDefined ( lastValue ) ;
1055
1051
if ( oneTimeParseFn . $$unwatch && self && self . $$postDigestQueue ) {
1056
1052
self . $$postDigestQueue . push ( function ( ) {
Original file line number Diff line number Diff line change @@ -114,6 +114,15 @@ describe('Scope', function() {
114
114
expect ( $rootScope . $$watchers . length ) . toEqual ( 0 ) ;
115
115
} ) ) ;
116
116
117
+ it ( 'should not keep constant literals on the watch queue' , inject ( function ( $rootScope ) {
118
+ $rootScope . $watch ( '[]' , function ( ) { } ) ;
119
+ $rootScope . $watch ( '{}' , function ( ) { } ) ;
120
+ expect ( $rootScope . $$watchers . length ) . toEqual ( 2 ) ;
121
+ $rootScope . $digest ( ) ;
122
+
123
+ expect ( $rootScope . $$watchers . length ) . toEqual ( 0 ) ;
124
+ } ) ) ;
125
+
117
126
it ( 'should clean up stable watches on the watch queue' , inject ( function ( $rootScope , $parse ) {
118
127
$rootScope . $watch ( $parse ( '::foo' ) , function ( ) { } ) ;
119
128
expect ( $rootScope . $$watchers . length ) . toEqual ( 1 ) ;
You can’t perform that action at this time.
0 commit comments