Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

htmlparser2

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

htmlparser2 - npm Package Compare versions

Comparing version 2.2.7 to 2.2.8

11

lib/DomHandler.js
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 @@ ]

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc