[MediaWiki-commits] [Gerrit] VisualEditor/VisualEditor[master]: DiffElement: Use document slices with full internal lists
jenkins-bot has submitted this change and it was merged. Change subject: DiffElement: Use document slices with full internal lists .. DiffElement: Use document slices with full internal lists Change-Id: I543e81c4dd6dbbd393304426fbc90e861f7982a5 --- M src/ui/elements/ve.ui.DiffElement.js 1 file changed, 10 insertions(+), 15 deletions(-) Approvals: Jforrester: Looks good to me, approved jenkins-bot: Verified diff --git a/src/ui/elements/ve.ui.DiffElement.js b/src/ui/elements/ve.ui.DiffElement.js index 6e6a9ed..30a0be0 100644 --- a/src/ui/elements/ve.ui.DiffElement.js +++ b/src/ui/elements/ve.ui.DiffElement.js @@ -157,23 +157,20 @@ * @return {string} HTML to display the action/move */ ve.ui.DiffElement.prototype.getNodeHtml = function ( node, action, move ) { - var nodeData, nodeDoc, nodeHtml; - - nodeDoc = action === 'remove' ? this.oldDoc : this.newDoc; + var nodeData, nodeHtml, + nodeDoc = action === 'remove' ? this.oldDoc : this.newDoc, + documentSlice = nodeDoc.cloneFromRange( node.getOuterRange() ); // Get the linear model for the node - nodeData = nodeDoc.getData( node.getOuterRange() ); + nodeData = documentSlice.data.data; // Add the classes to the outer element (in case there was a move) nodeData[ 0 ] = this.addClassesToNode( nodeData[ 0 ], nodeDoc, action, move ); // Get the html for the linear model with classes // Doc is always the new doc when inserting into the store - nodeHtml = ve.dm.converter.getDomFromModel( - nodeDoc.cloneWithData( - new ve.dm.ElementLinearData( this.newDoc.getStore(), nodeData ) - ) - ).body.innerHTML; + documentSlice.getStore().merge( this.newDoc.getStore() ); + nodeHtml = ve.dm.converter.getDomFromModel( documentSlice ).body.innerHTML; if ( action !== 'none' ) { nodeHtml = $( '' ).addClass( this.classPrefix + 'doc-child-change' ).append( nodeHtml ); @@ -195,7 +192,8 @@ iModified, jModified, classes, nodeHtml, newNodeIndex = this.oldToNew[ oldNodeIndex ].node, nodeRange = this.newDocChildren[ newNodeIndex ].getOuterRange(), - nodeData = this.newDoc.getData( nodeRange ), + documentSlice = this.newDoc.cloneFromRange( nodeRange ), + nodeData = documentSlice.data.data, alreadyProcessed = { remove: {}, insert: {} @@ -370,11 +368,8 @@ } } - nodeHtml = ve.dm.converter.getDomFromModel( - this.newDoc.cloneWithData( - new ve.dm.ElementLinearData( this.newDoc.getStore(), nodeData ) - ) - ).body.innerHTML; + documentSlice.getStore().merge( this.newDoc.getStore() ); + nodeHtml = ve.dm.converter.getDomFromModel( documentSlice ).body.innerHTML; // The following classes are used here: // * ve-ui-diffElement-doc-child-change -- To view, visit https://gerrit.wikimedia.org/r/322797 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I543e81c4dd6dbbd393304426fbc90e861f7982a5 Gerrit-PatchSet: 4 Gerrit-Project: VisualEditor/VisualEditor Gerrit-Branch: master Gerrit-Owner: EsandersGerrit-Reviewer: Catrope Gerrit-Reviewer: Divec Gerrit-Reviewer: Jforrester Gerrit-Reviewer: Sarahhaskins Gerrit-Reviewer: Tchanders Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] VisualEditor/VisualEditor[master]: DiffElement: Use document slices with full internal lists
Esanders has uploaded a new change for review. https://gerrit.wikimedia.org/r/322797 Change subject: DiffElement: Use document slices with full internal lists .. DiffElement: Use document slices with full internal lists Change-Id: I543e81c4dd6dbbd393304426fbc90e861f7982a5 --- M src/ui/elements/ve.ui.DiffElement.js 1 file changed, 10 insertions(+), 15 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor refs/changes/97/322797/1 diff --git a/src/ui/elements/ve.ui.DiffElement.js b/src/ui/elements/ve.ui.DiffElement.js index ff49850..5f5e527 100644 --- a/src/ui/elements/ve.ui.DiffElement.js +++ b/src/ui/elements/ve.ui.DiffElement.js @@ -153,23 +153,20 @@ * @return {string} HTML to display the action/move */ ve.ui.DiffElement.prototype.getNodeHtml = function ( node, action, move ) { - var nodeData, nodeDoc, nodeHtml; - - nodeDoc = action === 'remove' ? this.oldDoc : this.newDoc; + var nodeData, nodeHtml, + nodeDoc = action === 'remove' ? this.oldDoc : this.newDoc, + documentSlice = nodeDoc.cloneFromRange( node.getOuterRange() ); // Get the linear model for the node - nodeData = nodeDoc.getData( node.getOuterRange() ); + nodeData = documentSlice.data.data; // Add the classes to the outer element (in case there was a move) nodeData[ 0 ] = this.addClassesToNode( nodeData[ 0 ], nodeDoc, action, move ); // Get the html for the linear model with classes // Doc is always the new doc when inserting into the store - nodeHtml = ve.dm.converter.getDomFromModel( - nodeDoc.cloneWithData( - new ve.dm.ElementLinearData( this.newDoc.getStore(), nodeData ) - ) - ).body.innerHTML; + documentSlice.getStore().merge( this.newDoc.getStore() ); + nodeHtml = ve.dm.converter.getDomFromModel( documentSlice ).body.innerHTML; if ( action !== 'none' ) { nodeHtml = $( '' ).addClass( this.classPrefix + 'doc-child-change' ).append( nodeHtml ); @@ -191,7 +188,8 @@ iModified, jModified, classes, nodeHtml, newNodeIndex = this.oldToNew[ oldNodeIndex ].node, nodeRange = this.newDocChildren[ newNodeIndex ].getOuterRange(), - nodeData = this.newDoc.getData( nodeRange ), + documentSlice = this.newDoc.cloneFromRange( nodeRange ), + nodeData = documentSlice.data.data, alreadyProcessed = { remove: {}, insert: {} @@ -366,11 +364,8 @@ } } - nodeHtml = ve.dm.converter.getDomFromModel( - this.newDoc.cloneWithData( - new ve.dm.ElementLinearData( this.newDoc.getStore(), nodeData ) - ) - ).body.innerHTML; + documentSlice.getStore().merge( this.newDoc.getStore() ); + nodeHtml = ve.dm.converter.getDomFromModel( documentSlice ).body.innerHTML; // The following classes are used here: // * ve-ui-diffElement-doc-child-change -- To view, visit https://gerrit.wikimedia.org/r/322797 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I543e81c4dd6dbbd393304426fbc90e861f7982a5 Gerrit-PatchSet: 1 Gerrit-Project: VisualEditor/VisualEditor Gerrit-Branch: master Gerrit-Owner: Esanders___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits