diff --git a/lib/ext/Cite/index.js b/lib/ext/Cite/index.js
index e3a03f3fb..42251989a 100644
--- a/lib/ext/Cite/index.js
+++ b/lib/ext/Cite/index.js
@@ -5,6 +5,8 @@
'use strict';
+var domino = require('domino');
+
var ParsoidExtApi = module.parent.require('./extapi.js').versionCheck('^0.7.1');
var Util = ParsoidExtApi.Util;
var DU = ParsoidExtApi.DOMUtils;
@@ -41,7 +43,6 @@ function hasRef(node) {
}
c = c.nextSibling;
}
-
return false;
}
@@ -303,6 +304,8 @@ function References(cite) {
this.cite = cite;
}
+var dummyDoc = domino.createDocument();
+
/**
* Sanitize the references tag and convert it into a meta-token
*/
@@ -321,9 +324,13 @@ References.prototype.tokenHandler = function(manager, pipelineOpts, refsTok, cb)
// token so that the dom post processor can generate
// and emit references at this point in the DOM.
var emitReferencesFragment = function(toks, refsBody) {
- var olHTML = "
" + (refsBody || "") + "
";
+ var dummyOl = dummyDoc.createElement('ol');
+ DU.addAttributes(dummyOl, {
+ 'class': 'mw-references references',
+ typeof: 'mw:Extension/references',
+ about: referencesId,
+ });
+ dummyOl.innerHTML = refsBody || '';
var olProcessor = function(ol) {
var dp = DU.getDataParsoid(ol);
dp.src = refsTok.getAttribute('source');
@@ -337,7 +344,7 @@ References.prototype.tokenHandler = function(manager, pipelineOpts, refsTok, cb)
tokens: DU.buildDOMFragmentTokens(
manager.env,
refsTok,
- olHTML,
+ dummyOl.outerHTML,
olProcessor,
// The HTML above is wrapper HTML added on and doesn't
// have any DSR on it. We want DSR added to it.
@@ -530,7 +537,7 @@ References.prototype.insertMissingReferencesIntoDOM = function(refsData, node) {
var ol = doc.createElement('ol');
var dp = DU.getDataParsoid(ol);
DU.addAttributes(ol, {
- 'class': 'mw-references',
+ 'class': 'mw-references references',
typeof: 'mw:Extension/references',
about: env.newAboutId(),
});