Removed bubbling update events in dm and ce node trees and splice events from ce branches

The bubbling update events are not needed with ce or dm, but were once upon a time useful for es, this just eliminates some unused cruft that was costing extra function call overhead.

Change-Id: Ia16d0f4cd74c84cded5caecada33ee83d0882f30
This commit is contained in:
Trevor Parscal 2012-05-04 12:28:32 -07:00
parent 9887dbd96f
commit d2480baed0
2 changed files with 11 additions and 8 deletions

View file

@ -36,6 +36,17 @@ ve.ce.BranchNode.prototype.replaceDomWrapper = function( $element ) {
this.$ = $element;
};
/**
* Responds to splice events on a ve.dm.BranchNode.
*
* ve.ce.Node objects are generated from the inserted ve.dm.Node objects, producing a view that's a
* mirror of it's model.
*
* @method
* @param {Integer} index Index to remove and or insert nodes at
* @param {Integer} howmany Number of nodes to remove
* @param {ve.dm.BranchNode} [...] Variadic list of nodes to insert
*/
ve.ce.BranchNode.prototype.onSplice = function( index, howmany ) {
var i,
length,
@ -49,7 +60,6 @@ ve.ce.BranchNode.prototype.onSplice = function( index, howmany ) {
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 );
// Update DOM
removals[i].$.detach();
}
@ -61,7 +71,6 @@ ve.ce.BranchNode.prototype.onSplice = function( index, howmany ) {
}
for ( i = args.length - 1; i >= 2; i-- ) {
args[i].attach( this );
args[i].on( 'update', this.emitUpdate );
if ( index ) {
$anchor.after( args[i].$ );
} else {
@ -69,8 +78,6 @@ ve.ce.BranchNode.prototype.onSplice = function( index, howmany ) {
}
}
}
this.emit.apply( this, ['splice'].concat( args ) );
this.emit( 'update' );
};
/* Inheritance */

View file

@ -127,7 +127,6 @@ ve.dm.BranchNode.prototype.shift = function() {
* @param {ve.dm.BranchNode} [...] Variadic list of nodes to insert
* @returns {ve.dm.BranchNode[]} Removed nodes
* @emits splice (index, howmany, [...])
* @emits update
*/
ve.dm.BranchNode.prototype.splice = function( index, howmany ) {
var i,
@ -138,19 +137,16 @@ ve.dm.BranchNode.prototype.splice = function( index, howmany ) {
length = args.length;
for ( i = 2; i < length; i++ ) {
args[i].attach( this );
args[i].on( 'update', this.emitUpdate );
diff += args[i].getOuterLength();
}
}
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].getOuterLength();
}
this.adjustLength( diff, true );
this.emit.apply( this, ['splice'].concat( args ) );
this.emit( 'update' );
return removals;
};