summaryrefslogtreecommitdiffstats
path: root/toolkit/components/reader/JSDOMParser.js
diff options
context:
space:
mode:
authorAscrod <32915892+Ascrod@users.noreply.github.com>2018-06-01 21:32:59 -0400
committerAscrod <32915892+Ascrod@users.noreply.github.com>2018-06-02 15:49:59 -0400
commit984dad43ae49ba1cfa236af5567bf4c934e59263 (patch)
tree9a0e801344d8588d3b3f0d034313449c8a00e79f /toolkit/components/reader/JSDOMParser.js
parent7d9e2a108478d1fc79aa25b2ac56b62249e31dc5 (diff)
downloadUXP-984dad43ae49ba1cfa236af5567bf4c934e59263.tar
UXP-984dad43ae49ba1cfa236af5567bf4c934e59263.tar.gz
UXP-984dad43ae49ba1cfa236af5567bf4c934e59263.tar.lz
UXP-984dad43ae49ba1cfa236af5567bf4c934e59263.tar.xz
UXP-984dad43ae49ba1cfa236af5567bf4c934e59263.zip
Update Readability from mozilla-central release branch (FF 60.0).
Diffstat (limited to 'toolkit/components/reader/JSDOMParser.js')
-rw-r--r--toolkit/components/reader/JSDOMParser.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/toolkit/components/reader/JSDOMParser.js b/toolkit/components/reader/JSDOMParser.js
index 38f59c4ea..dd9d37230 100644
--- a/toolkit/components/reader/JSDOMParser.js
+++ b/toolkit/components/reader/JSDOMParser.js
@@ -560,7 +560,8 @@
},
};
- var Document = function () {
+ var Document = function (url) {
+ this.documentURI = url;
this.styleSheets = [];
this.childNodes = [];
this.children = [];
@@ -600,6 +601,20 @@
node.textContent = text;
return node;
},
+
+ get baseURI() {
+ if (!this.hasOwnProperty("_baseURI")) {
+ this._baseURI = this.documentURI;
+ var baseElements = this.getElementsByTagName("base");
+ var href = baseElements[0] && baseElements[0].getAttribute("href");
+ if (href) {
+ try {
+ this._baseURI = (new URL(href, this._baseURI)).href;
+ } catch (ex) {/* Just fall back to documentURI */}
+ }
+ }
+ return this._baseURI;
+ },
};
var Element = function (tag) {
@@ -1118,9 +1133,9 @@
/**
* Parses an HTML string and returns a JS implementation of the Document.
*/
- parse: function (html) {
+ parse: function (html, url) {
this.html = html;
- var doc = this.doc = new Document();
+ var doc = this.doc = new Document(url);
this.readChildren(doc);
// If this is an HTML document, remove root-level children except for the