Index: trunk/extensions/VisualEditor/modules/ve/dm/ve.dm.TransactionProcessor.js |
— | — | @@ -84,15 +84,24 @@ |
85 | 85 | |
86 | 86 | /* Methods */ |
87 | 87 | |
| 88 | +ve.dm.TransactionProcessor.prototype.nextOperation = function() { |
| 89 | + return this.operations[this.operationIndex++] || false; |
| 90 | +}; |
| 91 | + |
| 92 | +ve.dm.TransactionProcessor.prototype.executeOperation = function( op, method ) { |
| 93 | + if ( op.type in ve.dm.TransactionProcessor.operationMap ) { |
| 94 | + ve.dm.TransactionProcessor.operationMap[op.type][method].call( this, op ); |
| 95 | + } else { |
| 96 | + throw 'Invalid operation error. Operation type is not supported: ' + operation.type; |
| 97 | + } |
| 98 | +}; |
| 99 | + |
88 | 100 | ve.dm.TransactionProcessor.prototype.process = function( method ) { |
89 | | - var operations = this.transaction.getOperations(); |
90 | | - for ( var i = 0, length = operations.length; i < length; i++ ) { |
91 | | - var operation = operations[i]; |
92 | | - if ( operation.type in ve.dm.TransactionProcessor.operationMap ) { |
93 | | - ve.dm.TransactionProcessor.operationMap[operation.type][method].call( this, operation ); |
94 | | - } else { |
95 | | - throw 'Invalid operation error. Operation type is not supported: ' + operation.type; |
96 | | - } |
| 101 | + var op; |
| 102 | + this.operations = this.transaction.getOperations(); |
| 103 | + this.operationIndex = 0; |
| 104 | + while ( ( op = this.nextOperation() ) ) { |
| 105 | + this.executeOperation( op, method ); |
97 | 106 | } |
98 | 107 | }; |
99 | 108 | |