File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,12 @@ describe('DeltaSnapshot', () => {
137137 populate ( { myKey : 'foo' , myOtherKey : 'bar' } , { myKey : null } ) ;
138138 expect ( subject . val ( ) ) . to . deep . equal ( { myOtherKey : 'bar' } ) ;
139139 } ) ;
140+
141+ // Regression test: .val() was returning array of nulls when there's a property called length (BUG#37683995)
142+ it ( 'should return correct values when data has "length" property' , ( ) => {
143+ populate ( null , { length : 3 , foo : 'bar' } ) ;
144+ expect ( subject . val ( ) ) . to . deep . equal ( { length : 3 , foo : 'bar' } ) ;
145+ } ) ;
140146 } ) ;
141147
142148 describe ( '#child(): DeltaSnapshot' , ( ) => {
Original file line number Diff line number Diff line change @@ -248,7 +248,9 @@ export class DeltaSnapshot implements firebase.database.DataSnapshot {
248248 let numKeys = 0 ;
249249 let maxKey = 0 ;
250250 let allIntegerKeys = true ;
251- _ . forEach ( node , ( childNode , key ) => {
251+ for ( let key in node ) {
252+ if ( ! node . hasOwnProperty ( key ) ) { continue ; }
253+ let childNode = node [ key ] ;
252254 obj [ key ] = this . _checkAndConvertToArray ( childNode ) ;
253255 numKeys ++ ;
254256 const integerRegExp = / ^ ( 0 | [ 1 - 9 ] \d * ) $ / ;
@@ -257,7 +259,7 @@ export class DeltaSnapshot implements firebase.database.DataSnapshot {
257259 } else {
258260 allIntegerKeys = false ;
259261 }
260- } ) ;
262+ }
261263
262264 if ( allIntegerKeys && maxKey < 2 * numKeys ) {
263265 // convert to array.
You can’t perform that action at this time.
0 commit comments