Index: trunk/extensions/VisualEditor/modules/es/bases/es.DocumentModelBranchNode.js |
— | — | @@ -153,20 +153,21 @@ |
154 | 154 | this.emit.apply( this, ['beforeSplice'].concat( args ) ); |
155 | 155 | if ( args.length >= 3 ) { |
156 | 156 | for ( i = 2, length = args.length; i < length; i++ ) { |
| 157 | + args[i].attach( this ); |
| 158 | + args[i].on( 'update', this.emitUpdate ); |
157 | 159 | diff += args[i].getElementLength(); |
158 | | - args[i].attach( this ); |
159 | 160 | } |
160 | 161 | } |
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(); |
166 | 167 | } |
167 | 168 | this.adjustContentLength( diff, true ); |
168 | 169 | this.emit.apply( this, ['afterSplice'].concat( args ) ); |
169 | 170 | this.emit( 'update' ); |
170 | | - return removed; |
| 171 | + return removals; |
171 | 172 | }; |
172 | 173 | |
173 | 174 | /** |