Socket
Socket
Sign inDemoInstall

domhandler

Package Overview
Dependencies
0
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.0 to 1.3.1

43

lib/handler.js

@@ -48,10 +48,23 @@ var ElementType = require("./ElementType.js"),

if(!lastTag){ //There aren't parent elements
if(lastTag){
lastTag.children.push(element);
} else { //There aren't parent elements
this.dom.push(element);
return;
}
};
if(DomUtils.isTag(element)){
element.parent = lastTag;
DomHandler.prototype.onopentag = function(name, attribs){
var lastTag = this._tagStack[this._tagStack.length - 1];
var element = {
type: name === "script" ? ElementType.Script : name === "style" ? ElementType.Style : ElementType.Tag,
name: name,
attribs: attribs,
children: [],
prev: null,
next: null,
parent: lastTag || null
};
if(lastTag){
var idx = lastTag.children.length;

@@ -65,18 +78,7 @@ while(idx > 0){

}
lastTag.children.push(element);
} else {
this.dom.push(element);
}
lastTag.children.push(element);
};
DomHandler.prototype.onopentag = function(name, attribs){
var element = {
type: name === "script" ? ElementType.Script : name === "style" ? ElementType.Style : ElementType.Tag,
name: name,
attribs: attribs,
children: [],
prev: null,
next: null,
parent: null
};
this._addDomElement(element);
this._tagStack.push(element);

@@ -92,4 +94,3 @@ };

(lastTag = this._tagStack[this._tagStack.length - 1]) &&
(lastTag = lastTag.children) &&
(lastTag = lastTag[lastTag.length - 1]) &&
(lastTag = lastTag.children[lastTag.children.length - 1]) &&
lastTag.type === ElementType.Text

@@ -96,0 +97,0 @@ ){

{
"name": "domhandler",
"version": "1.3.0",
"version": "1.3.1",
"description": "htmlparser2's dom as a separate module",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -12,4 +12,3 @@ {

"name": "br",
"attribs": {},
"children": null
"attribs": {}
},

@@ -23,6 +22,5 @@ {

"name": "br",
"attribs": {},
"children": null
"attribs": {}
}
]
}

@@ -12,4 +12,3 @@ {

"name": "br",
"attribs": {},
"children": null
"attribs": {}
},

@@ -23,6 +22,5 @@ {

"name": "br",
"attribs": {},
"children": null
"attribs": {}
}
]
}

@@ -15,6 +15,5 @@ {

"selected": ""
},
"children": null
}
}
]
}

@@ -16,4 +16,3 @@ {

"name": "br",
"attribs": {},
"children": null
"attribs": {}
},

@@ -20,0 +19,0 @@ {

@@ -18,4 +18,3 @@ {

"name": "br",
"attribs": {},
"children": null
"attribs": {}
},

@@ -25,4 +24,3 @@ {

"name": "br",
"attribs": {},
"children": null
"attribs": {}
},

@@ -41,4 +39,3 @@ {

"name": "br",
"attribs": {},
"children": null
"attribs": {}
},

@@ -45,0 +42,0 @@ {

@@ -12,4 +12,3 @@ {

"name": "link",
"attribs": {},
"children": null
"attribs": {}
},

@@ -16,0 +15,0 @@ {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc