https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113853
Revision: 113853
Author: catrope
Date: 2012-03-14 21:02:34 +0000 (Wed, 14 Mar 2012)
Log Message:
-----------
Factor out process() into nextOperation() and executeOperation()
Modified Paths:
--------------
trunk/extensions/VisualEditor/modules/ve/dm/ve.dm.TransactionProcessor.js
Modified:
trunk/extensions/VisualEditor/modules/ve/dm/ve.dm.TransactionProcessor.js
===================================================================
--- trunk/extensions/VisualEditor/modules/ve/dm/ve.dm.TransactionProcessor.js
2012-03-14 21:02:33 UTC (rev 113852)
+++ trunk/extensions/VisualEditor/modules/ve/dm/ve.dm.TransactionProcessor.js
2012-03-14 21:02:34 UTC (rev 113853)
@@ -84,15 +84,24 @@
/* Methods */
+ve.dm.TransactionProcessor.prototype.nextOperation = function() {
+ return this.operations[this.operationIndex++] || false;
+};
+
+ve.dm.TransactionProcessor.prototype.executeOperation = function( op, method )
{
+ if ( op.type in ve.dm.TransactionProcessor.operationMap ) {
+ ve.dm.TransactionProcessor.operationMap[op.type][method].call(
this, op );
+ } else {
+ throw 'Invalid operation error. Operation type is not
supported: ' + operation.type;
+ }
+};
+
ve.dm.TransactionProcessor.prototype.process = function( method ) {
- var operations = this.transaction.getOperations();
- for ( var i = 0, length = operations.length; i < length; i++ ) {
- var operation = operations[i];
- if ( operation.type in ve.dm.TransactionProcessor.operationMap
) {
-
ve.dm.TransactionProcessor.operationMap[operation.type][method].call( this,
operation );
- } else {
- throw 'Invalid operation error. Operation type is not
supported: ' + operation.type;
- }
+ var op;
+ this.operations = this.transaction.getOperations();
+ this.operationIndex = 0;
+ while ( ( op = this.nextOperation() ) ) {
+ this.executeOperation( op, method );
}
};
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs