mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 16:20:52 +00:00
Merge "Node cleanup"
This commit is contained in:
commit
9a96f894ff
|
@ -290,7 +290,7 @@ ve.ce.Node.prototype.getModel = function () {
|
|||
ve.ce.Node.getSplitableNode = function ( node ) {
|
||||
var splitableNode = null;
|
||||
|
||||
ve.Node.traverseUpstream( node, function ( node ) {
|
||||
node.traverseUpstream( function ( node ) {
|
||||
if ( node.canBeSplit() ) {
|
||||
splitableNode = node;
|
||||
return true;
|
||||
|
|
|
@ -836,7 +836,7 @@ ve.ce.Surface.prototype.handleEnter = function ( e ) {
|
|||
}
|
||||
} else {
|
||||
// Split
|
||||
ve.Node.traverseUpstream( node, function ( node ) {
|
||||
node.traverseUpstream( function ( node ) {
|
||||
if ( !node.canBeSplit() ) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1026,7 +1026,7 @@ ve.ce.Surface.prototype.handleDelete = function ( e, backspace ) {
|
|||
|
||||
// Find the node that should be completely removed
|
||||
nodeToDelete = sourceNode;
|
||||
ve.Node.traverseUpstream( nodeToDelete, function ( node ) {
|
||||
nodeToDelete.traverseUpstream( function ( node ) {
|
||||
if ( node.getParent().children.length === 1 ) {
|
||||
nodeToDelete = node.getParent();
|
||||
return true;
|
||||
|
|
|
@ -23,13 +23,6 @@ ve.Node = function VeNode( type ) {
|
|||
this.parent = null;
|
||||
this.root = this;
|
||||
this.doc = null;
|
||||
|
||||
// Convenience function for emitting update events - context is bound by enclosing this scope
|
||||
// making it easy to pass through other functions as a callback
|
||||
var node = this;
|
||||
this.emitUpdate = function () {
|
||||
node.emit( 'update' );
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -206,11 +199,11 @@ ve.Node.prototype.detach = function () {
|
|||
*
|
||||
* For each traversed node, the callback function will be passed the traversed node as a parameter.
|
||||
*
|
||||
* @param {ve.Node} node Node from which to start traversing
|
||||
* @param {Function} callback Callback method to be called for every traversed node
|
||||
* @method
|
||||
*/
|
||||
ve.Node.traverseUpstream = function ( node, callback ) {
|
||||
ve.Node.prototype.traverseUpstream = function ( callback ) {
|
||||
var node = this;
|
||||
while ( node ) {
|
||||
if ( callback ( node ) === false ) {
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue