diff options
author | Ascrod <32915892+Ascrod@users.noreply.github.com> | 2018-10-15 13:52:23 -0400 |
---|---|---|
committer | Ascrod <32915892+Ascrod@users.noreply.github.com> | 2018-10-15 13:52:23 -0400 |
commit | f696173b4af510cf72885282efcfdd3c4005fbb1 (patch) | |
tree | 95a35079f11c854bd89d20d5eaf78eedfef66104 /toolkit/components/reader/JSDOMParser.js | |
parent | f6db3fa9044b5a928cb5d19dfb5b6b3283949326 (diff) | |
download | UXP-f696173b4af510cf72885282efcfdd3c4005fbb1.tar UXP-f696173b4af510cf72885282efcfdd3c4005fbb1.tar.gz UXP-f696173b4af510cf72885282efcfdd3c4005fbb1.tar.lz UXP-f696173b4af510cf72885282efcfdd3c4005fbb1.tar.xz UXP-f696173b4af510cf72885282efcfdd3c4005fbb1.zip |
Update Readability from mozilla-central release branch (FF 62.0.3). Tag #361.
Diffstat (limited to 'toolkit/components/reader/JSDOMParser.js')
-rw-r--r-- | toolkit/components/reader/JSDOMParser.js | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/toolkit/components/reader/JSDOMParser.js b/toolkit/components/reader/JSDOMParser.js index dd9d37230..debdb08eb 100644 --- a/toolkit/components/reader/JSDOMParser.js +++ b/toolkit/components/reader/JSDOMParser.js @@ -618,6 +618,13 @@ }; var Element = function (tag) { + // We use this to find the closing tag. + this._matchingTag = tag; + // We're explicitly a non-namespace aware parser, we just pretend it's all HTML. + var lastColonIndex = tag.lastIndexOf(":"); + if (lastColonIndex != -1) { + tag = tag.substring(lastColonIndex + 1); + } this.attributes = []; this.childNodes = []; this.children = []; @@ -785,7 +792,13 @@ break; } } - } + }, + + hasAttribute: function (name) { + return this.attributes.some(function (attr) { + return attr.name == name; + }); + }, }; var Style = function (node) { @@ -1062,9 +1075,10 @@ return null; // Read any text as Text node + var textNode; if (c !== "<") { --this.currentChar; - var textNode = new Text(); + textNode = new Text(); var n = this.html.indexOf("<", this.currentChar); if (n === -1) { textNode.innerHTML = this.html.substring(this.currentChar, this.html.length); @@ -1076,6 +1090,18 @@ return textNode; } + if (this.match("![CDATA[")) { + var endChar = this.html.indexOf("]]>", this.currentChar); + if (endChar === -1) { + this.error("unclosed CDATA section"); + return null; + } + textNode = new Text(); + textNode.textContent = this.html.substring(this.currentChar, endChar); + this.currentChar = endChar + ("]]>").length; + return textNode; + } + c = this.peekNext(); // Read Comment node. Normally, Comment nodes know their inner @@ -1107,7 +1133,7 @@ // If this isn't a void Element, read its child nodes if (!closed) { this.readChildren(node); - var closingTag = "</" + localName + ">"; + var closingTag = "</" + node._matchingTag + ">"; if (!this.match(closingTag)) { this.error("expected '" + closingTag + "' and got " + this.html.substr(this.currentChar, closingTag.length)); return null; |