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

parse5

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse5 - npm Package Compare versions

Comparing version 1.1.5 to 1.1.6

77

lib/tree_adapters/htmlparser2.js
'use strict';
//Conversion tables for DOM Level1 structure emulation
var nodeTypes = {
element: 1,
text: 3,
cdata: 4,
comment: 8
};
var nodePropertyShorthands = {
tagName: 'name',
childNodes: 'children',
parentNode: 'parent',
previousSibling: 'prev',
nextSibling: 'next',
nodeValue: 'data'
};
//Node
var Node = function (props) {
for (var key in props) {
if (props.hasOwnProperty(key))
this[key] = props[key];
}
};
Node.prototype = {
get firstChild() {
var children = this.children;
return children && children[0] || null;
},
get lastChild() {
var children = this.children;
return children && children[children.length - 1] || null;
},
get nodeType() {
return nodeTypes[this.type] || nodeTypes.element;
}
};
Object.keys(nodePropertyShorthands).forEach(function (key) {
var shorthand = nodePropertyShorthands[key];
Object.defineProperty(Node.prototype, key, {
get: function () {
return this[shorthand] || null;
},
set: function (val) {
this[shorthand] = val;
return val;
}
});
});
//Node construction
exports.createDocument =
exports.createDocumentFragment = function () {
return {
return new Node({
type: 'root',

@@ -13,3 +69,3 @@ name: 'root',

children: []
};
});
};

@@ -30,6 +86,5 @@

return {
return new Node({
type: tagName === 'script' || tagName === 'style' ? tagName : 'tag',
name: tagName,
tagName: tagName,
namespace: namespaceURI,

@@ -43,7 +98,7 @@ attribs: attribs,

next: null
};
});
};
exports.createCommentNode = function (data) {
return {
return new Node({
type: 'comment',

@@ -54,7 +109,7 @@ data: data,

next: null
};
});
};
var createTextNode = function (value) {
return {
return new Node({
type: 'text',

@@ -65,3 +120,3 @@ data: value,

next: null
}
});
};

@@ -100,3 +155,3 @@

else {
appendChild(document, {
appendChild(document, new Node({
type: 'directive',

@@ -108,3 +163,3 @@ name: '!doctype',

'x-systemId': systemId
});
}));
}

@@ -111,0 +166,0 @@

2

package.json
{
"name": "parse5",
"description": "WHATWG HTML5 specification-compliant, fast and ready for production HTML parsing/serialization toolset for Node.",
"version": "1.1.5",
"version": "1.1.6",
"author": "Ivan Nikulin <ifaaan@gmail.com> (https://github.com/inikulin)",

@@ -6,0 +6,0 @@ "contributors": [

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