Socket
Socket
Sign inDemoInstall

hast-util-from-parse5

Package Overview
Dependencies
7
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.1 to 2.1.0

51

index.js
'use strict';
/* Dependencies. */
var information = require('property-information');

@@ -9,3 +8,2 @@ var camelcase = require('camelcase');

/* Expose. */
module.exports = wrapper;

@@ -85,15 +83,21 @@

function root(ast, children, config) {
var node = {
type: 'root',
children: children,
data: {
quirksMode: ast.mode === 'quirks' || ast.mode === 'limited-quirks'
var quirks = ast.mode === 'quirks' || ast.mode === 'limited-quirks';
var node = {type: 'root', children: children};
var position;
node.data = {quirksMode: quirks};
if (ast.__location) {
if (config.toPosition) {
config.location = true;
position = ast.__location;
}
};
} else if (config.file && config.location) {
position = {startOffset: 0, endOffset: String(config.file).length};
}
if (config.file && config.location) {
node.position = location({
startOffset: 0,
endOffset: String(config.file).length
}, ast, node, config);
position = position && location(position, ast, node, config);
if (position) {
node.position = position;
}

@@ -125,3 +129,3 @@

/* Transform an element. */
function element(ast, children) {
function element(ast, children, config) {
var props = {};

@@ -132,2 +136,4 @@ var values = ast.attrs;

var attr;
var node;
var fragment;

@@ -139,3 +145,18 @@ while (++index < length) {

return h(ast.tagName, props, children);
node = h(ast.tagName, props, children);
if (ast.nodeName === 'template' && 'content' in ast) {
fragment = ast.content;
if (ast.__location) {
fragment.__location = {
startOffset: ast.__location.startTag.endOffset,
endOffset: ast.__location.endTag.startOffset
};
}
node.content = transform(ast.content, config);
}
return node;
}

@@ -142,0 +163,0 @@

{
"name": "hast-util-from-parse5",
"version": "2.0.1",
"version": "2.1.0",
"description": "Transform Parse5’s AST to HAST",

@@ -12,6 +12,3 @@ "license": "MIT",

],
"files": [
"index.js"
],
"repository": "https://github.com/syntax-tree/hast-util-from-parse5",
"repository": "syntax-tree/hast-util-from-parse5",
"bugs": "https://github.com/syntax-tree/hast-util-from-parse5/issues",

@@ -22,2 +19,5 @@ "author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",

],
"files": [
"index.js"
],
"dependencies": {

@@ -32,2 +32,4 @@ "camelcase": "^3.0.0",

"esmangle": "^1.0.1",
"is-hidden": "^1.1.0",
"not": "^0.1.0",
"nyc": "^11.0.0",

@@ -38,2 +40,3 @@ "parse5": "^3.0.0",

"tape": "^4.0.0",
"unist-util-visit": "^1.1.3",
"vfile": "^2.0.0",

@@ -40,0 +43,0 @@ "xo": "^0.18.0"

@@ -7,3 +7,3 @@ # hast-util-from-parse5 [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]

[npm][npm-install]:
[npm][]:

@@ -30,3 +30,3 @@ ```bash

var doc = vfile.readSync('example.html')
var doc = vfile.readSync('example.html');
var ast = parse5.parse(String(doc), {locationInfo: true});

@@ -137,3 +137,3 @@ var hast = fromParse5(ast, doc);

[npm-install]: https://docs.npmjs.com/cli/install
[npm]: https://docs.npmjs.com/cli/install

@@ -140,0 +140,0 @@ [license]: LICENSE

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc