@@ -296,7 +296,12 @@ <h4>[[dinosaur.__firebaseKey__]]</h4>
296296 var key ;
297297 var value ;
298298
299- if ( pathParts . length < 2 || pathParts [ 1 ] === 'splices' ) {
299+ if ( pathParts . length < 2 || pathParts [ 1 ] === 'length' ) {
300+ return ;
301+ }
302+
303+ if ( pathParts [ 1 ] === 'splices' ) {
304+ this . _applySplicesToRemoteData ( change . value . indexSplices ) ;
300305 return ;
301306 }
302307
@@ -312,6 +317,23 @@ <h4>[[dinosaur.__firebaseKey__]]</h4>
312317 value . __firebaseKey__ = firebaseKey ;
313318 } ,
314319
320+ _applySplicesToRemoteData : function ( splices ) {
321+ this . _log ( 'splices' , splices ) ;
322+ splices . forEach ( function ( splice ) {
323+ var added = splice . object . slice ( splice . index , splice . index + splice . addedCount ) ;
324+
325+ splice . removed . forEach ( function ( removed ) {
326+ this . remove ( removed ) ;
327+ } , this ) ;
328+
329+ this . data . splice ( splice . index , splice . addedCount ) ;
330+
331+ added . forEach ( function ( added ) {
332+ this . add ( added ) ;
333+ } , this ) ;
334+ } , this ) ;
335+ } ,
336+
315337 _computeQuery : function ( location , limitToFirst , limitToLast , orderByMethodName , startAt , endAt , equalTo ) {
316338 var query ;
317339
@@ -454,14 +476,19 @@ <h4>[[dinosaur.__firebaseKey__]]</h4>
454476 this . _applyRemoteDataChange ( function ( ) {
455477 var key = event . detail . oldChildSnapshot . key ( ) ;
456478 var value = this . _valueMap [ key ] ;
479+ var index ;
457480
458481 if ( ! value ) {
459482 this . _error ( 'Received firebase-child-removed event for unknown child "' + key + '"' ) ;
460483 return ;
461484 }
462485
486+ index = this . data . indexOf ( value ) ;
463487 this . _valueMap [ key ] = null ;
464- this . splice ( 'data' , this . data . indexOf ( value ) , 1 ) ;
488+
489+ if ( index !== - 1 ) {
490+ this . splice ( 'data' , index , 1 ) ;
491+ }
465492 } ) ;
466493 } ,
467494
0 commit comments