From 53117cef543ef64bc364de0d488042c3de18e6c9 Mon Sep 17 00:00:00 2001 From: Subramanya Sastry Date: Thu, 24 Mar 2016 15:19:14 -0500 Subject: [PATCH] T113331: Move auto-generated refs flag from data-parsoid to data-mw VisualEditor requires this info and presumably other clients might and this is, in reality, semantic information about wikitext. The html2html failure is because: * even when the references html has been autogenerated, in non-rt-testing html2wt mode, we always generate the tag. * we moved the flag from data-parsoid to data-mw but ignore changes to data-parsoid while comparing test output. * So, in html -> wt mode, is always generated => data-mw.autoGenerated flag doesn't show up in the wt -> html phase of the (html -> wt -> html) test => the html2html test fails. Change-Id: I8e79f2a436a1ca276b9351228a3d8f02d7ebd0c6 --- lib/ext/Cite.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/ext/Cite.js b/lib/ext/Cite.js index 7b77735ce..df8bf07dd 100644 --- a/lib/ext/Cite.js +++ b/lib/ext/Cite.js @@ -481,11 +481,11 @@ References.prototype.extractRefFromNode = function(node, refsData, } }; -References.prototype.insertReferencesIntoDOM = function(refsNode, refsData, refsInReferencesHTML) { +References.prototype.insertReferencesIntoDOM = function(refsNode, refsData, refsInReferencesHTML, autoGenerated) { var dp = DU.getDataParsoid(refsNode); var group = dp.group || ''; - var dataMw = DU.getDataMw(refsNode); + var dataMw = DU.getDataMw(refsNode); if (!Object.keys(dataMw).length) { dataMw = { 'name': 'references', @@ -495,6 +495,12 @@ References.prototype.insertReferencesIntoDOM = function(refsNode, refsData, refs }, }; + // Mark this auto-generated so that we can skip this during + // html -> wt and so that clients can strip it if necessary. + if (autoGenerated) { + dataMw.autoGenerated = true; + } + var src = dp.src || ''; // fall back so we don't crash // Extract ext-source for .. usage var body = Util.extractExtBody('references', src).trim(); @@ -541,7 +547,6 @@ References.prototype.insertMissingReferencesIntoDOM = function(env, refsData, no // The new references come out of "nowhere", so to make selser work // propertly, add a zero-sized DSR pointing to the end of the document. dp.dsr = [env.page.src.length, env.page.src.length, 0, 0]; - dp.autoInsertedRefs = true; if (refsGroup) { ol.setAttribute('data-mw-group', refsGroup); dp.group = refsGroup; @@ -552,20 +557,19 @@ References.prototype.insertMissingReferencesIntoDOM = function(env, refsData, no // each tag appears on its own line. node.appendChild(doc.createTextNode("\n")); node.appendChild(ol); - self.insertReferencesIntoDOM(ol, refsData, [""]); + self.insertReferencesIntoDOM(ol, refsData, [""], true); }); }; References.prototype.serialHandler = { handle: Promise.method(function(node, state, wrapperUnmodified) { - var dp = DU.getDataParsoid(node); - if (dp.autoInsertedRefs && state.rtTestMode) { + var dataMw = DU.getDataMw(node); + if (dataMw.autoGenerated && state.rtTestMode) { // Eliminate auto-inserted noise in rt-testing return Promise.resolve(''); } else { return state.serializer.serializeExtensionStartTag(node, state) .then(function(startTagSrc) { - var dataMw = DU.getDataMw(node); if (!dataMw.body) { return startTagSrc; // We self-closed this already. } else if (typeof dataMw.body.html === 'string') {