r103012 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103011‎ | r103012 | r103013 >
Date:19:47, 14 November 2011
Author:tparscal
Status:deferred
Tags:
Comment:
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) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/bases/es.DocumentModelBranchNode.js
@@ -153,20 +153,21 @@
154154 this.emit.apply( this, ['beforeSplice'].concat( args ) );
155155 if ( args.length >= 3 ) {
156156 for ( i = 2, length = args.length; i < length; i++ ) {
 157+ args[i].attach( this );
 158+ args[i].on( 'update', this.emitUpdate );
157159 diff += args[i].getElementLength();
158 - args[i].attach( this );
159160 }
160161 }
161 - var removed = this.children.splice.apply( this.children, args );
162 - for ( i = 0, length = removed.length; i < length; i++ ) {
163 - diff -= removed[i].getElementLength();
164 - removed[i].detach();
165 - removed[i].removeListener( 'update', this.emitUpdate );
 162+ var removals = this.children.splice.apply( this.children, args );
 163+ for ( i = 0, length = removals.length; i < length; i++ ) {
 164+ removals[i].detach();
 165+ removals[i].removeListener( 'update', this.emitUpdate );
 166+ diff -= removals[i].getElementLength();
166167 }
167168 this.adjustContentLength( diff, true );
168169 this.emit.apply( this, ['afterSplice'].concat( args ) );
169170 this.emit( 'update' );
170 - return removed;
 171+ return removals;
171172 };
172173
173174 /**

Status & tagging log