This repository was archived by the owner on Jul 5, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -784,7 +784,7 @@ defineScalyrAngularModule('gatedScope', [])
784784 // circuit it with === operator, only when === fails do we use .equals
785785 if ( watch && ( value = watch . get ( current ) ) !== ( last = watch . last ) &&
786786 ! ( watch . eq
787- ? equals ( value , last )
787+ ? areEqual ( value , last )
788788 : ( typeof value == 'number' && typeof last == 'number'
789789 && isNaN ( value ) && isNaN ( last ) ) ) ) {
790790 dirty = true ;
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ defineScalyrAngularModule('gatedScope', [])
8686 // circuit it with === operator, only when === fails do we use .equals
8787 if ( watch && ( value = watch . get ( current ) ) !== ( last = watch . last ) &&
8888 ! ( watch . eq
89- ? equals ( value , last )
89+ ? areEqual ( value , last )
9090 : ( typeof value == 'number' && typeof last == 'number'
9191 && isNaN ( value ) && isNaN ( last ) ) ) ) {
9292 dirty = true ;
Original file line number Diff line number Diff line change @@ -256,4 +256,26 @@ describe('GatedScope', function() {
256256 $rootScope . $digest ( ) ;
257257 expect ( counter ) . toEqual ( 4 ) ;
258258 } ) ;
259+
260+ it ( 'should evaluate watchers registered with equality equal to true' , function ( ) {
261+ var objectToWatch = { value : 5 } ;
262+
263+ var counter = 0 ;
264+ function watcher ( ) {
265+ ++ counter ;
266+ return objectToWatch ;
267+ }
268+
269+ // Add a gate so that all future watchers are evaluated using our version of $digest.
270+ var scope = $rootScope . $new ( ) ;
271+ scope . $addWatcherGate ( function ( ) {
272+ return true ;
273+ } ) ;
274+
275+ scope . $watch ( watcher , function ( newValue ) {
276+ } , true ) ;
277+
278+ // When both gates are down, the watcher should not be evaluated.
279+ $rootScope . $digest ( ) ;
280+ } ) ;
259281} ) ;
You can’t perform that action at this time.
0 commit comments