https://www.mediawiki.org/wiki/Special:Code/MediaWiki/103012

Revision: 103012
Author:   tparscal
Date:     2011-11-14 19:47:44 +0000 (Mon, 14 Nov 2011)
Log Message:
-----------
Fixed order of operations and added missing attach operation to splicing nodes 
in a model branch

Modified Paths:
--------------
    trunk/extensions/VisualEditor/modules/es/bases/es.DocumentModelBranchNode.js

Modified: 
trunk/extensions/VisualEditor/modules/es/bases/es.DocumentModelBranchNode.js
===================================================================
--- 
trunk/extensions/VisualEditor/modules/es/bases/es.DocumentModelBranchNode.js    
    2011-11-14 19:44:13 UTC (rev 103011)
+++ 
trunk/extensions/VisualEditor/modules/es/bases/es.DocumentModelBranchNode.js    
    2011-11-14 19:47:44 UTC (rev 103012)
@@ -153,20 +153,21 @@
        this.emit.apply( this, ['beforeSplice'].concat( args ) );
        if ( args.length >= 3 ) {
                for ( i = 2, length = args.length; i < length; i++ ) {
+                       args[i].attach( this );
+                       args[i].on( 'update', this.emitUpdate );
                        diff += args[i].getElementLength();
-                       args[i].attach( this );
                }
        }
-       var removed = this.children.splice.apply( this.children, args );
-       for ( i = 0, length = removed.length; i < length; i++ ) {
-               diff -= removed[i].getElementLength();
-               removed[i].detach();
-               removed[i].removeListener( 'update', this.emitUpdate );
+       var removals = this.children.splice.apply( this.children, args );
+       for ( i = 0, length = removals.length; i < length; i++ ) {
+               removals[i].detach();
+               removals[i].removeListener( 'update', this.emitUpdate );
+               diff -= removals[i].getElementLength();
        }
        this.adjustContentLength( diff, true );
        this.emit.apply( this, ['afterSplice'].concat( args ) );
        this.emit( 'update' );
-       return removed;
+       return removals;
 };
 
 /**


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to