jenkins-bot has submitted this change and it was merged.
Change subject: ve.dm.Transaction: add 'author' field
......................................................................
ve.dm.Transaction: add 'author' field
Also remove toJSON method, as it is no longer needed
Change-Id: Icfbd542d0c66ecc656bd734d1d1fb44dd1869d90
---
M src/dm/ve.dm.Transaction.js
M src/ve.debug.js
M tests/dm/ve.dm.Transaction.test.js
3 files changed, 7 insertions(+), 13 deletions(-)
Approvals:
Jforrester: Looks good to me, approved
Esanders: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/src/dm/ve.dm.Transaction.js b/src/dm/ve.dm.Transaction.js
index 251aea7..11cb1a0 100644
--- a/src/dm/ve.dm.Transaction.js
+++ b/src/dm/ve.dm.Transaction.js
@@ -25,6 +25,7 @@
ve.dm.Transaction = function VeDmTransaction( operations ) {
this.operations = operations || [];
this.applied = false;
+ this.author = null;
};
/* Static Methods */
@@ -904,15 +905,6 @@
/* Methods */
/**
- * Get a serializable object describing the transaction
- *
- * @return {Object} Serializable object
- */
-ve.dm.Transaction.prototype.toJSON = function () {
- return this.operations;
-};
-
-/**
* Create a clone of this transaction.
*
* The returned transaction will be exactly the same as this one, except that
its 'applied' flag
@@ -924,6 +916,7 @@
ve.dm.Transaction.prototype.clone = function () {
var tx = new this.constructor();
tx.operations = ve.copy( this.operations );
+ tx.author = this.author;
return tx;
};
@@ -951,6 +944,7 @@
}
tx.operations.push( newOp );
}
+ tx.author = this.author;
return tx;
};
diff --git a/src/ve.debug.js b/src/ve.debug.js
index f6c7b54..27cbc4e 100644
--- a/src/ve.debug.js
+++ b/src/ve.debug.js
@@ -122,7 +122,7 @@
}
} ).join( '' ) + '\'';
}
- return '(' + tx.operations.map( function ( op ) {
+ return '(' + tx.author + ' ' + tx.operations.map( function ( op ) {
if ( op.type === 'retain' ) {
return ( annotations ? 'annotate ' : 'retain ' ) +
op.length;
} else if ( op.type === 'replace' ) {
diff --git a/tests/dm/ve.dm.Transaction.test.js
b/tests/dm/ve.dm.Transaction.test.js
index 6001f7e..2c8bd6d 100644
--- a/tests/dm/ve.dm.Transaction.test.js
+++ b/tests/dm/ve.dm.Transaction.test.js
@@ -2464,7 +2464,7 @@
} );
} );
-QUnit.test( 'toJSON/build with operations', function ( assert ) {
+QUnit.test( 'operations/build from operations', function ( assert ) {
var i, tx, ops,
doc = ve.dm.example.createExampleDocument(),
underline = ve.dm.example.createAnnotation(
ve.dm.example.underline ),
@@ -2545,8 +2545,8 @@
for ( i = 0; i < cases.length; i++ ) {
tx = ve.dm.Transaction[ cases[ i ].method ].apply(
ve.dm.Transaction, cases[ i ].args );
- ops = JSON.parse( JSON.stringify( tx.toJSON() ) );
- assert.deepEqual( ops, cases[ i ].expected, cases[ i ].msg + ':
toJSON' );
+ ops = ve.copy( tx.operations );
+ assert.deepEqual( ops, cases[ i ].expected, cases[ i ].msg + ':
operations' );
if ( cases[ i ].roundTripArgs ) {
tx = ve.dm.Transaction[ cases[ i ].method ].apply(
ve.dm.Transaction, cases[ i ].roundTripArgs );
}
--
To view, visit https://gerrit.wikimedia.org/r/317373
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icfbd542d0c66ecc656bd734d1d1fb44dd1869d90
Gerrit-PatchSet: 4
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Divec <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits