r103569 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103568‎ | r103569 | r103570 >
Date:05:18, 18 November 2011
Author:inez
Status:deferred
Tags:
Comment:
Added static function es.DocumentNode.traverseUpstream
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/bases/es.DocumentNode.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/bases/es.DocumentNode.js
@@ -52,6 +52,23 @@
5353 throw 'DocumentNode.hasChildren not implemented in this subclass:' + this.constructor;
5454 };
5555
 56+/**
 57+ * Traverse tree of nodes (model or view) upstream and for each traversed node call callback function passing traversed node as a parameter.
 58+ * Callback function is called for node passed as node paramter as well.
 59+ *
 60+ * @param {es.DocumentNode} node Node from which to start traversing
 61+ * @param {function} callback Callback method to be called for every traversed node
 62+ * @method
 63+ */
 64+es.DocumentNode.traverseUpstream = function( node, callback ) {
 65+ while ( node ) {
 66+ if ( callback ( node ) === false ) {
 67+ break;
 68+ }
 69+ node = node.getParent();
 70+ }
 71+};
 72+
5673 /* Inheritance */
5774
58 -es.extendClass( es.DocumentNode, es.EventEmitter );
 75+es.extendClass( es.DocumentNode, es.EventEmitter );
\ No newline at end of file

Status & tagging log