Catrope has submitted this change and it was merged. Change subject: Wrap text nodes in spans if trying to mark as data-ve-ignore ......................................................................
Wrap text nodes in spans if trying to mark as data-ve-ignore Otherwise you're going to have a bad time. Bug: 59002 Change-Id: Ifd90087b3d36f412420b9786f3d54a5418846d03 (cherry picked from commit b2b9f217da0fcc0795d59fdc54f2059b79d48b1c) --- M modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js 1 file changed, 8 insertions(+), 2 deletions(-) Approvals: Catrope: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js b/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js index 3a3a815..b602cf0 100644 --- a/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js +++ b/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js @@ -89,7 +89,7 @@ }; ve.dm.MWTransclusionNode.static.toDomElements = function ( dataElement, doc, converter ) { - var els, currentDom, i, len, + var els, currentDom, i, len, wrapper, index = converter.getStore().indexOfHash( OO.getHash( [ this.getHashObject( dataElement ), undefined ] ) ), originalMw = dataElement.attributes.originalMw; @@ -113,8 +113,14 @@ currentDom = converter.getStore().value( index ); if ( currentDom ) { currentDom = ve.copyDomElements( currentDom, doc ); - // i = 0 is the span + // i = 0 is the data-mw span for ( i = 1, len = currentDom.length; i < len; i++ ) { + // Wrap plain text nodes so we can give them an attribute + if ( currentDom[i].nodeType === Node.TEXT_NODE ) { + wrapper = doc.createElement( 'span' ); + wrapper.appendChild( currentDom[i] ); + currentDom[i] = wrapper; + } currentDom[i].setAttribute( 'data-ve-ignore', 'true' ); els.push( currentDom[i] ); } -- To view, visit https://gerrit.wikimedia.org/r/107530 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ifd90087b3d36f412420b9786f3d54a5418846d03 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: wmf/1.23wmf10 Gerrit-Owner: Catrope <roan.katt...@gmail.com> Gerrit-Reviewer: Catrope <roan.katt...@gmail.com> Gerrit-Reviewer: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits