@@ -357,6 +357,7 @@ var FireQueryActor = ActorClass(
357
357
return ;
358
358
}
359
359
360
+ // Bail out if the element has already been cached as modified.
360
361
if ( this . modifiedElements . has ( element ) ) {
361
362
return ;
362
363
}
@@ -368,22 +369,46 @@ var FireQueryActor = ActorClass(
368
369
} ) ,
369
370
370
371
/**
371
- * Send chunk of modified elements.
372
+ * Send chunk of modified elements after a timeout .
372
373
*/
373
- sendDataModified : function ( ) {
374
+ sendDataModified : makeInfallible ( function ( ) {
374
375
this . modifiedElementsTimeout = null ;
375
376
377
+ let walkerActor = this . conn . getActor ( this . walkerActorID ) ;
378
+
379
+ // WalkerActor.hasNode() method has been introduced in Firefox 43.
380
+ // See also: https://bugzilla.mozilla.org/show_bug.cgi?id=1195742
381
+ // TODO: The workaround can be removed when Fx43 is the minimum
382
+ // requirement FIXME.
383
+ let hasNode = typeof ( walkerActor . hasNode ) == "function" ?
384
+ walkerActor . hasNode . bind ( walkerActor ) :
385
+ walkerActor . _refMap . has . bind ( walkerActor . _refMap ) ;
386
+
387
+ // This is an important optimization that can filter list of
388
+ // packets send to the client down to the bare minimum.
389
+ // Make sure all modifiedElements are still known by the walker,
390
+ // they could have been removed during the timeout or they haven't
391
+ // even been imported by the client yet.
392
+ for ( let node of this . modifiedElements ) {
393
+ if ( ! hasNode ( node ) ) {
394
+ this . modifiedElements . delete ( node ) ;
395
+ }
396
+ }
397
+
398
+ // Bail out if there is nothing to send.
376
399
if ( ! this . modifiedElements . size ) {
377
400
return ;
378
401
}
379
402
380
- let walkerActor = this . conn . getActor ( this . walkerActorID ) ;
381
403
let data = walkerActor . attachElements ( this . modifiedElements ) ;
382
404
405
+ // Clean up the cache with modified elements.
383
406
this . modifiedElements . clear ( ) ;
384
407
408
+ // Send data modified event to the client,
409
+ // so the UI can be updated.
385
410
Events . emit ( this , "data-modified" , data ) ;
386
- } ,
411
+ } ) ,
387
412
388
413
/**
389
414
* Returns jQuery data for given node.
0 commit comments