hast-util-to-parse5
Advanced tools
Comparing version 2.1.0 to 2.2.0
48
index.js
@@ -6,3 +6,2 @@ 'use strict'; | ||
var NS = require('web-namespaces'); | ||
var has = require('has'); | ||
var zwitch = require('zwitch'); | ||
@@ -13,5 +12,8 @@ var mapz = require('mapz'); | ||
var own = {}.hasOwnProperty; | ||
var one = zwitch('type'); | ||
var all = mapz(one, {key: 'children', indices: false}); | ||
var customProps = ['__location', 'childNodes', 'content', 'parentNode', 'namespaceURI']; | ||
one.handlers.root = root; | ||
@@ -52,3 +54,3 @@ one.handlers.element = element; | ||
var data = node.data || {}; | ||
var qs = has(data, 'quirksMode') ? Boolean(data.quirksMode) : false; | ||
var qs = own.call(data, 'quirksMode') ? Boolean(data.quirksMode) : false; | ||
@@ -69,18 +71,22 @@ return { | ||
var values = []; | ||
var content; | ||
var value; | ||
var key; | ||
for (key in attrs) { | ||
if (has(attributeSpaces, key)) { | ||
values.push(xtend({ | ||
name: key, | ||
value: attrs[key] | ||
}, attributeSpaces[key])); | ||
} else { | ||
values.push({ | ||
name: key, | ||
value: attrs[key] | ||
}); | ||
value = {name: key, value: attrs[key]}; | ||
if (own.call(attributeSpaces, key)) { | ||
value = xtend(value, attributeSpaces[key]); | ||
} | ||
values.push(value); | ||
} | ||
if (name === 'template') { | ||
content = transform(shallow.content); | ||
delete content.mode; | ||
content.nodeName = '#document-fragment'; | ||
} | ||
return wrap(node, { | ||
@@ -91,3 +97,3 @@ nodeName: node.tagName, | ||
childNodes: node.children ? all(node) : [] | ||
}); | ||
}, content); | ||
}, shallow); | ||
@@ -120,3 +126,3 @@ } | ||
/* Patch position. */ | ||
function wrap(node, ast) { | ||
function wrap(node, ast, content) { | ||
if (node.position && node.position.start && node.position.end) { | ||
@@ -131,2 +137,6 @@ ast.__location = { | ||
if (content) { | ||
ast.content = content; | ||
} | ||
return ast; | ||
@@ -147,3 +157,3 @@ } | ||
for (key in node) { | ||
if (key !== '__location' && key !== 'childNodes') { | ||
if (customProps.indexOf(key) === -1) { | ||
replacement[key] = node[key]; | ||
@@ -153,7 +163,7 @@ } | ||
if (has(namespaces, name)) { | ||
if (own.call(namespaces, name)) { | ||
ns = namespaces[name]; | ||
} | ||
if (has(replacement, 'tagName')) { | ||
if (own.call(replacement, 'tagName')) { | ||
replacement.namespaceURI = ns; | ||
@@ -172,2 +182,6 @@ } | ||
if (name === 'template') { | ||
replacement.content = patch(node.content, null, ns); | ||
} | ||
if (parent) { | ||
@@ -174,0 +188,0 @@ replacement.parentNode = parent; |
{ | ||
"name": "hast-util-to-parse5", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Transform HAST to Parse5’s AST", | ||
@@ -12,6 +12,3 @@ "license": "MIT", | ||
], | ||
"files": [ | ||
"index.js" | ||
], | ||
"repository": "https://github.com/syntax-tree/hast-util-to-parse5", | ||
"repository": "syntax-tree/hast-util-to-parse5", | ||
"bugs": "https://github.com/syntax-tree/hast-util-to-parse5/issues", | ||
@@ -22,4 +19,6 @@ "author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
], | ||
"files": [ | ||
"index.js" | ||
], | ||
"dependencies": { | ||
"has": "^1.0.1", | ||
"hast-to-hyperscript": "^3.0.0", | ||
@@ -34,6 +33,6 @@ "mapz": "^1.0.0", | ||
"esmangle": "^1.0.1", | ||
"nyc": "^10.0.0", | ||
"nyc": "^11.0.0", | ||
"parse5": "^3.0.0", | ||
"remark-cli": "^3.0.0", | ||
"remark-preset-wooorm": "^2.0.0", | ||
"remark-cli": "^4.0.0", | ||
"remark-preset-wooorm": "^3.0.0", | ||
"tape": "^4.0.0", | ||
@@ -40,0 +39,0 @@ "xo": "^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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
8781
5
152
- Removedhas@^1.0.1
- Removedhas@1.0.4(transitive)