diff --git a/chrome/content/zotero/xpcom/style.js b/chrome/content/zotero/xpcom/style.js index 1f04b69a8f..42e33154c0 100644 --- a/chrome/content/zotero/xpcom/style.js +++ b/chrome/content/zotero/xpcom/style.js @@ -845,8 +845,11 @@ Zotero.Style.prototype.getCiteProc = function (locale, format, options = {}) { let styleDOMXML = new DOMParser() .parseFromString(this.getXML(), "text/xml"); - // apply XSLT and serialize output - let newDOMXML = Zotero.Styles.xsltProcessor.transformToDocument(styleDOMXML); + // apply XSLT and serialize output. transformToFragment() is used because + // transformToDocument() needs a load group, which it takes from the source + // document or from the window that created the processor, and there's + // neither here. + let newDOMXML = Zotero.Styles.xsltProcessor.transformToFragment(styleDOMXML, styleDOMXML); var xml = new XMLSerializer().serializeToString(newDOMXML); } else { var xml = this.getXML(); diff --git a/test/tests/styleTest.js b/test/tests/styleTest.js index 1e86b930fa..1bbb0f4807 100644 --- a/test/tests/styleTest.js +++ b/test/tests/styleTest.js @@ -253,4 +253,30 @@ describe("Zotero.Styles", function () { assert.equal(style.effectiveLocale, "en-US"); }); }); + + describe("CSL 0.8 styles", function () { + var csl08Style = ` + + `; + + it("should upgrade a style to CSL 1.0 and format a bibliography", async function () { + var item = await createDataObject('item', { title: 'Foo Bar' }); + var style = new Zotero.Style(csl08Style); + assert.equal(style._version, "0.8"); + var cslEngine = style.getCiteProc('en-US', 'text'); + var text = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, [item], "text"); + assert.equal(text, 'Foo Bar\n'); + }); + }); });