diff --git a/lib/ext/Cite.js b/lib/ext/Cite.js index b28f0494b..7b77735ce 100644 --- a/lib/ext/Cite.js +++ b/lib/ext/Cite.js @@ -484,32 +484,24 @@ References.prototype.extractRefFromNode = function(node, refsData, References.prototype.insertReferencesIntoDOM = function(refsNode, refsData, refsInReferencesHTML) { var dp = DU.getDataParsoid(refsNode); var group = dp.group || ''; - var src = dp.src || ''; // fall back so we don't crash - // Extract ext-source for .. usage - var body = Util.extractExtBody("references", src).trim(); - var refGroup = refsData.getRefGroup(group); var dataMw = DU.getDataMw(refsNode); if (!Object.keys(dataMw).length) { - var datamwBody; - // We'll have to output data-mw.body.extsrc in - // scenarios where original wikitext was of the form: - // " lot of refs here " - // Ex: See [[en:Barack Obama]] - if (body.length > 0) { - datamwBody = { - 'extsrc': body, - 'html': refsInReferencesHTML.join(''), - }; - } dataMw = { 'name': 'references', - 'body': datamwBody, 'attrs': { // Dont emit empty keys 'group': group || undefined, }, }; + + var src = dp.src || ''; // fall back so we don't crash + // Extract ext-source for .. usage + var body = Util.extractExtBody('references', src).trim(); + if (body.length > 0) { + dataMw.body = { 'html': refsInReferencesHTML.join('') }; + } + DU.setDataMw(refsNode, dataMw); } @@ -522,6 +514,7 @@ References.prototype.insertReferencesIntoDOM = function(refsNode, refsData, refs refsNode.removeChild(refsNode.firstChild); } + var refGroup = refsData.getRefGroup(group); if (refGroup) { refGroup.refs.forEach(refGroup.renderLine.bind(refGroup, refsNode)); }