From 363961a9e2e2ea92bbd8d98d25b6a8f5c5d0fb15 Mon Sep 17 00:00:00 2001 From: Trevor Parscal Date: Fri, 1 Feb 2013 15:35:48 -0800 Subject: [PATCH] Node cleanup ve.Node.js * Removed unused emitUpdate property * Made traverseUpstream a dynamic method rather than static ve.ce.Node.js, ve.ce.Surface.js * Updated calls to traverseUpstream Change-Id: I28a2dac61aa32668d35854fbdb7712401c42336a --- modules/ve/ce/ve.ce.Node.js | 2 +- modules/ve/ce/ve.ce.Surface.js | 4 ++-- modules/ve/ve.Node.js | 11 ++--------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/modules/ve/ce/ve.ce.Node.js b/modules/ve/ce/ve.ce.Node.js index 5c588e8301..74d10a8054 100644 --- a/modules/ve/ce/ve.ce.Node.js +++ b/modules/ve/ce/ve.ce.Node.js @@ -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; diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js index af52298ae2..3ce5ac1866 100644 --- a/modules/ve/ce/ve.ce.Surface.js +++ b/modules/ve/ce/ve.ce.Surface.js @@ -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; diff --git a/modules/ve/ve.Node.js b/modules/ve/ve.Node.js index babba5d290..bfb7819399 100644 --- a/modules/ve/ve.Node.js +++ b/modules/ve/ve.Node.js @@ -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;