This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -376,7 +376,7 @@ function $RootScopeProvider(){
376
376
oldValue = newValue ;
377
377
changeDetected ++ ;
378
378
}
379
- } else if ( isArray ( newValue ) ) {
379
+ } else if ( isArrayLike ( newValue ) ) {
380
380
if ( oldValue !== internalArray ) {
381
381
// we are transitioning from something which was not an array into array.
382
382
oldValue = internalArray ;
Original file line number Diff line number Diff line change @@ -463,6 +463,23 @@ describe('Scope', function() {
463
463
$rootScope . $digest ( ) ;
464
464
expect ( log ) . toEqual ( [ '[{},[]]' ] ) ;
465
465
} ) ;
466
+
467
+ it ( 'should watch array-like objects like arrays' , function ( ) {
468
+ var arrayLikelog = [ ] ;
469
+ $rootScope . $watchCollection ( 'arrayLikeObject' , function logger ( obj ) {
470
+ forEach ( obj , function ( element ) {
471
+ arrayLikelog . push ( element . name ) ;
472
+ } )
473
+ } ) ;
474
+ document . body . innerHTML = "<p>" +
475
+ "<a name='x'>a</a>" +
476
+ "<a name='y'>b</a>" +
477
+ "</p>" ;
478
+
479
+ $rootScope . arrayLikeObject = document . getElementsByTagName ( 'a' )
480
+ $rootScope . $digest ( ) ;
481
+ expect ( arrayLikelog ) . toEqual ( [ 'x' , 'y' ] ) ;
482
+ } ) ;
466
483
} ) ;
467
484
468
485
You can’t perform that action at this time.
0 commit comments