htmlparser2
Advanced tools
Comparing version 2.2.7 to 2.2.8
var ElementType = require("./ElementType.js"); | ||
function DomHandler(callback, options){ | ||
var optionsObjectFirst = typeof callback === "object"; | ||
this._options = optionsObjectFirst ? callback : options || defaultOpts; | ||
this._callback = optionsObjectFirst ? null : callback; | ||
this._options = typeof callback === "object" ? callback : options || defaultOpts; | ||
this._callback = typeof callback === "object" ? null : callback; | ||
this.dom = []; | ||
@@ -14,3 +13,4 @@ this._done = false; | ||
var defaultOpts = { | ||
ignoreWhitespace: false //Keep whitespace-only text nodes | ||
ignoreWhitespace: false, //Keep whitespace-only text nodes | ||
refParent: false //add a reference to the elements parent node | ||
}; | ||
@@ -48,2 +48,5 @@ | ||
if(lastTag){ //There are parent elements | ||
if(this._options.refParent){ | ||
element.parent = lastTag; | ||
} | ||
if(!lastTag.children){ | ||
@@ -50,0 +53,0 @@ lastTag.children = [element]; |
@@ -175,8 +175,3 @@ var ElementType = require("./ElementType.js"); | ||
else if(elementData.charAt(0) === "!"){ | ||
if(elementData.substr(1, 2) === "--"){ | ||
//This tag is a comment | ||
this._contentFlags |= SpecialTags[ElementType.Comment]; | ||
this._writeComment(rawData.substr(3)); | ||
} | ||
else if(elementData.substr(1, 7) === "[CDATA["){ | ||
if(elementData.substr(1, 7) === "[CDATA["){ | ||
this._contentFlags |= SpecialTags[ElementType.CDATA]; | ||
@@ -187,2 +182,7 @@ if(this._cbs.oncdatastart) this._cbs.oncdatastart(); | ||
else if(this._contentFlags !== 0) this._writeSpecial(rawData, lastTagSep); | ||
else if(elementData.substr(1, 2) === "--"){ | ||
//This tag is a comment | ||
this._contentFlags |= SpecialTags[ElementType.Comment]; | ||
this._writeComment(rawData.substr(3)); | ||
} | ||
//TODO: This isn't a processing instruction, needs a new name | ||
@@ -189,0 +189,0 @@ else if(this._cbs.onprocessinginstruction){ |
{ | ||
"name": "htmlparser2", | ||
"description": "Performance-optimized forgiving HTML/XML/RSS parser", | ||
"version": "2.2.7", | ||
"version": "2.2.8", | ||
"author": "Felix Boehm <me@feedic.com>", | ||
@@ -6,0 +6,0 @@ "keywords": ["html", "parser", "streams", "xml", "dom", "rss", "feed", "atom"], |
@@ -14,4 +14,4 @@ { | ||
{ | ||
"data": "var foo = 1;", | ||
"type": "comment" | ||
"data": "<!--var foo = 1;-->", | ||
"type": "text" | ||
} | ||
@@ -18,0 +18,0 @@ ] |
@@ -14,12 +14,4 @@ { | ||
{ | ||
"data": "this is ", | ||
"data": "this is <!-- the comment --> the text", | ||
"type": "text" | ||
}, | ||
{ | ||
"data": " the comment ", | ||
"type": "comment" | ||
}, | ||
{ | ||
"data": " the text", | ||
"type": "text" | ||
} | ||
@@ -26,0 +18,0 @@ ] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79745
3084