fx-compat: Replace nsIDOMParser
with new DOMParser()
This commit is contained in:
parent
993320655e
commit
dd2ff63019
14 changed files with 19 additions and 38 deletions
|
@ -180,8 +180,7 @@ Zotero.Cite = {
|
|||
if(lineSpacing == NaN) throw new Error("Invalid linespacing");
|
||||
|
||||
var str;
|
||||
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser),
|
||||
var parser = new DOMParser(),
|
||||
doc = parser.parseFromString("<!DOCTYPE html><html><body></body></html>", "text/html");
|
||||
doc.body.insertAdjacentHTML("afterbegin", html);
|
||||
var div = doc.body.firstChild,
|
||||
|
|
|
@ -183,8 +183,7 @@ Zotero.HTTPIntegrationClient.Field.prototype.getText = async function() {
|
|||
Zotero.HTTPIntegrationClient.Field.prototype.setText = async function(text, isRich) {
|
||||
// The HTML will be stripped by Google Docs and and since we're
|
||||
// caching this value, we need to strip it ourselves
|
||||
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser);
|
||||
var parser = new DOMParser();
|
||||
var doc = parser.parseFromString(text, "text/html");
|
||||
this._text = doc.documentElement.textContent;
|
||||
return Zotero.HTTPIntegrationClient.sendCommand("Field.setText", [this._documentID, this._id, text, true]);
|
||||
|
|
|
@ -493,8 +493,7 @@ Zotero.Server.Connector.Detect.prototype = {
|
|||
)
|
||||
: null;
|
||||
|
||||
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser);
|
||||
var parser = new DOMParser();
|
||||
var doc = parser.parseFromString(`<html>${data.html}</html>`, 'text/html');
|
||||
doc = Zotero.HTTP.wrapDocument(doc, data.uri);
|
||||
|
||||
|
@ -1186,8 +1185,7 @@ Zotero.Server.Connector.SaveSnapshot.prototype = {
|
|||
return item;
|
||||
}
|
||||
|
||||
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser);
|
||||
var parser = new DOMParser();
|
||||
parser.init(null, Services.io.newURI(data.url));
|
||||
var doc = parser.parseFromString(`<html>${data.html}</html>`, 'text/html');
|
||||
doc = Zotero.HTTP.wrapDocument(doc, data.url);
|
||||
|
|
|
@ -118,8 +118,7 @@ Zotero.Feeds = new function() {
|
|||
}
|
||||
|
||||
this.importFromOPML = Zotero.Promise.coroutine(function* (opmlString) {
|
||||
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser);
|
||||
var parser = new DOMParser();
|
||||
var doc = parser.parseFromString(opmlString, "application/xml");
|
||||
// Per some random spec (https://developer.mozilla.org/en-US/docs/Web/API/DOMParser),
|
||||
// DOMParser returns a special type of xml document on error, so we do some magic checking here.
|
||||
|
|
|
@ -2459,8 +2459,7 @@ Zotero.Integration.DocumentData.prototype.serialize = function() {
|
|||
* Unserializes document-specific XML
|
||||
*/
|
||||
Zotero.Integration.DocumentData.prototype.unserializeXML = function(xmlData) {
|
||||
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser),
|
||||
var parser = new DOMParser(),
|
||||
doc = parser.parseFromString(xmlData, "application/xml");
|
||||
|
||||
this.sessionID = Zotero.Utilities.xpathText(doc, '/data/session[1]/@id');
|
||||
|
|
|
@ -301,8 +301,7 @@ Zotero.LocateManager = new function() {
|
|||
"http://a9.com/-/spec/opensearchdescription/1.0/"
|
||||
];
|
||||
|
||||
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser),
|
||||
var parser = new DOMParser(),
|
||||
doc = parser.parseFromString(xmlStr, "application/xml"),
|
||||
docEl = doc.documentElement,
|
||||
ns = docEl.namespaceURI,
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
Zotero.Report = {};
|
||||
|
||||
Zotero.Report.HTML = new function () {
|
||||
let domParser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser);
|
||||
let domParser = new DOMParser();
|
||||
|
||||
this.listGenerator = function* (items, combineChildItems, libraryID) {
|
||||
yield '<!DOCTYPE html>\n'
|
||||
|
|
|
@ -1168,8 +1168,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = {
|
|||
}
|
||||
|
||||
var seconds = false;
|
||||
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser);
|
||||
var parser = new DOMParser();
|
||||
try {
|
||||
var xml = parser.parseFromString(req.responseText, "text/xml");
|
||||
}
|
||||
|
|
|
@ -336,8 +336,7 @@ Zotero.Styles = new function() {
|
|||
var existingFile, destFile, source;
|
||||
|
||||
// First, parse style and make sure it's valid XML
|
||||
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser),
|
||||
var parser = new DOMParser(),
|
||||
doc = parser.parseFromString(style, "application/xml");
|
||||
|
||||
var styleID = Zotero.Utilities.xpathText(doc, '/csl:style/csl:info[1]/csl:id[1]',
|
||||
|
@ -626,8 +625,7 @@ Zotero.Style = function (style, path) {
|
|||
|
||||
this.type = "csl";
|
||||
|
||||
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser),
|
||||
var parser = new DOMParser(),
|
||||
doc = parser.parseFromString(style, "application/xml");
|
||||
if(doc.documentElement.localName === "parsererror") {
|
||||
throw new Error("File is not valid XML");
|
||||
|
@ -737,8 +735,7 @@ Zotero.Style.prototype.getCiteProc = function(locale, format, automaticJournalAb
|
|||
// get XSLT processor from updateCSL.xsl file
|
||||
if(!Zotero.Styles.xsltProcessor) {
|
||||
let xsl = Zotero.File.getContentsFromURL("chrome://zotero/content/updateCSL.xsl");
|
||||
let updateXSLT = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser)
|
||||
let updateXSLT = new DOMParser()
|
||||
.parseFromString(xsl, "application/xml");
|
||||
|
||||
// XSLTProcessor is no longer available in XPCOM, so get from hidden window
|
||||
|
@ -750,8 +747,7 @@ Zotero.Style.prototype.getCiteProc = function(locale, format, automaticJournalAb
|
|||
}
|
||||
|
||||
// read style file as DOM XML
|
||||
let styleDOMXML = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser)
|
||||
let styleDOMXML = new DOMParser()
|
||||
.parseFromString(this.getXML(), "text/xml");
|
||||
|
||||
// apply XSLT and serialize output
|
||||
|
|
|
@ -1762,8 +1762,7 @@ Zotero.Sync.Data.Local = {
|
|||
|
||||
var localChanged = false;
|
||||
var normalizeHTML = (str) => {
|
||||
let parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser);
|
||||
let parser = new DOMParser();
|
||||
str = parser.parseFromString(str, 'text/html');
|
||||
str = str.body.textContent;
|
||||
// Normalize internal spaces
|
||||
|
|
|
@ -384,8 +384,7 @@ Zotero.Translate.SandboxManager = function(sandboxLocation) {
|
|||
FIRST_ORDERED_NODE_TYPE: 9
|
||||
},
|
||||
DOMParser: function() {
|
||||
return Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser);
|
||||
return new DOMParser();
|
||||
},
|
||||
XMLSerializer: function() {
|
||||
return Components.classes["@mozilla.org/xmlextras/xmlserializer;1"]
|
||||
|
|
|
@ -795,8 +795,7 @@ Zotero.Utilities.Internal = {
|
|||
* Returns a DOMDocument object not attached to any window
|
||||
*/
|
||||
"getDOMDocument": function() {
|
||||
return Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser)
|
||||
return new DOMParser()
|
||||
.parseFromString("<!DOCTYPE html><html></html>", "text/html");
|
||||
},
|
||||
|
||||
|
|
|
@ -2449,8 +2449,7 @@ describe("Connector Server", function () {
|
|||
|
||||
it('should import a style with application/vnd.citationstyles.style+xml content-type', function* () {
|
||||
sinon.stub(Zotero.Styles, 'install').callsFake(function(style) {
|
||||
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser),
|
||||
var parser = new DOMParser(),
|
||||
doc = parser.parseFromString(style, "application/xml");
|
||||
|
||||
return Zotero.Promise.resolve({
|
||||
|
@ -2478,8 +2477,7 @@ describe("Connector Server", function () {
|
|||
|
||||
it('should accept text/plain request with X-Zotero-Connector-API-Version or Zotero-Allowed-Request', async function () {
|
||||
sinon.stub(Zotero.Styles, 'install').callsFake(function(style) {
|
||||
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser),
|
||||
var parser = new DOMParser(),
|
||||
doc = parser.parseFromString(style, "application/xml");
|
||||
|
||||
return Zotero.Promise.resolve({
|
||||
|
|
|
@ -420,8 +420,7 @@ describe("Zotero.Sync.Storage.Mode.WebDAV", function () {
|
|||
req.respond(201, { "Fake-Server-Match": 1 }, "");
|
||||
}
|
||||
else if (req.method == "PUT" && req.url == `${davURL}zotero/${item.key}.prop`) {
|
||||
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser);
|
||||
var parser = new DOMParser();
|
||||
var doc = parser.parseFromString(req.requestBody, "text/xml");
|
||||
assert.equal(
|
||||
doc.documentElement.getElementsByTagName('mtime')[0].textContent, mtime
|
||||
|
|
Loading…
Reference in a new issue