hast-util-from-parse5
Advanced tools
Comparing version 7.1.1 to 7.1.2
@@ -1,3 +0,3 @@ | ||
export {fromParse5} from './lib/index.js' | ||
export type Options = import('./lib/index.js').Options | ||
export type Space = import('./lib/index.js').Space | ||
export { fromParse5 } from "./lib/index.js"; | ||
export type Options = import('./lib/index.js').Options; | ||
export type Space = import('./lib/index.js').Space; |
@@ -11,29 +11,26 @@ /** | ||
*/ | ||
export function fromParse5( | ||
tree: P5Node, | ||
options?: Options | VFile | null | undefined | ||
): Node | ||
export type VFile = import('vfile').VFile | ||
export type Schema = import('property-information').Schema | ||
export type Position = import('unist').Position | ||
export type Point = import('unist').Point | ||
export type Element = import('hast').Element | ||
export type Root = import('hast').Root | ||
export type Content = import('hast').Content | ||
export type DefaultTreeAdapterMap = import('parse5').DefaultTreeAdapterMap | ||
export type P5ElementLocation = import('parse5').Token.ElementLocation | ||
export type P5Location = import('parse5').Token.Location | ||
export type Node = Content | Root | ||
export type P5Document = DefaultTreeAdapterMap['document'] | ||
export type P5DocumentFragment = DefaultTreeAdapterMap['documentFragment'] | ||
export type P5DocumentType = DefaultTreeAdapterMap['documentType'] | ||
export type P5Comment = DefaultTreeAdapterMap['commentNode'] | ||
export type P5Text = DefaultTreeAdapterMap['textNode'] | ||
export type P5Element = DefaultTreeAdapterMap['element'] | ||
export type P5Node = DefaultTreeAdapterMap['node'] | ||
export type P5Template = DefaultTreeAdapterMap['template'] | ||
export function fromParse5(tree: P5Node, options?: Options | VFile | null | undefined): Node; | ||
export type VFile = import('vfile').VFile; | ||
export type Schema = import('property-information').Schema; | ||
export type Position = import('unist').Position; | ||
export type Point = import('unist').Point; | ||
export type Element = import('hast').Element; | ||
export type Root = import('hast').Root; | ||
export type Content = import('hast').Content; | ||
export type DefaultTreeAdapterMap = import('parse5').DefaultTreeAdapterMap; | ||
export type P5ElementLocation = import('parse5').Token.ElementLocation; | ||
export type P5Location = import('parse5').Token.Location; | ||
export type Node = Content | Root; | ||
export type P5Document = DefaultTreeAdapterMap['document']; | ||
export type P5DocumentFragment = DefaultTreeAdapterMap['documentFragment']; | ||
export type P5DocumentType = DefaultTreeAdapterMap['documentType']; | ||
export type P5Comment = DefaultTreeAdapterMap['commentNode']; | ||
export type P5Text = DefaultTreeAdapterMap['textNode']; | ||
export type P5Element = DefaultTreeAdapterMap['element']; | ||
export type P5Node = DefaultTreeAdapterMap['node']; | ||
export type P5Template = DefaultTreeAdapterMap['template']; | ||
/** | ||
* Namespace. | ||
*/ | ||
export type Space = 'html' | 'svg' | ||
export type Space = 'html' | 'svg'; | ||
/** | ||
@@ -43,24 +40,24 @@ * Configuration. | ||
export type Options = { | ||
/** | ||
* Which space the document is in. | ||
* | ||
* When an `<svg>` element is found in the HTML space, this package already | ||
* automatically switches to and from the SVG space when entering and exiting | ||
* it. | ||
*/ | ||
space?: Space | null | undefined | ||
/** | ||
* File used to add positional info to nodes. | ||
* | ||
* If given, the file should represent the original HTML source. | ||
*/ | ||
file?: VFile | null | undefined | ||
/** | ||
* Whether to add extra positional info about starting tags, closing tags, | ||
* and attributes to elements. | ||
* | ||
* > 👉 **Note**: only used when `file` is given. | ||
*/ | ||
verbose?: boolean | undefined | ||
} | ||
/** | ||
* Which space the document is in. | ||
* | ||
* When an `<svg>` element is found in the HTML space, this package already | ||
* automatically switches to and from the SVG space when entering and exiting | ||
* it. | ||
*/ | ||
space?: Space | null | undefined; | ||
/** | ||
* File used to add positional info to nodes. | ||
* | ||
* If given, the file should represent the original HTML source. | ||
*/ | ||
file?: VFile | null | undefined; | ||
/** | ||
* Whether to add extra positional info about starting tags, closing tags, | ||
* and attributes to elements. | ||
* | ||
* > 👉 **Note**: only used when `file` is given. | ||
*/ | ||
verbose?: boolean | undefined; | ||
}; | ||
/** | ||
@@ -70,18 +67,18 @@ * Info passed around about the current state. | ||
export type State = { | ||
/** | ||
* Current schema. | ||
*/ | ||
schema: Schema | ||
/** | ||
* Corresponding file. | ||
*/ | ||
file: VFile | undefined | ||
/** | ||
* Add extra positional info. | ||
*/ | ||
verbose: boolean | undefined | ||
/** | ||
* Whether location info was found. | ||
*/ | ||
location: boolean | ||
} | ||
/** | ||
* Current schema. | ||
*/ | ||
schema: Schema; | ||
/** | ||
* Corresponding file. | ||
*/ | ||
file: VFile | undefined; | ||
/** | ||
* Add extra positional info. | ||
*/ | ||
verbose: boolean | undefined; | ||
/** | ||
* Whether location info was found. | ||
*/ | ||
location: boolean; | ||
}; |
@@ -64,2 +64,5 @@ /** | ||
const own = {}.hasOwnProperty | ||
/** @type {unknown} */ | ||
// type-coverage:ignore-next-line | ||
const proto = Object.prototype | ||
@@ -141,3 +144,6 @@ /** | ||
const loc = location(doc) | ||
result.position = {start: loc.toPoint(0), end: loc.toPoint(doc.length)} | ||
const start = loc.toPoint(0) | ||
const end = loc.toPoint(doc.length) | ||
// @ts-expect-error: always defined as we give valid input. | ||
result.position = {start, end} | ||
} | ||
@@ -217,4 +223,7 @@ | ||
const attribute = node.attrs[index] | ||
props[(attribute.prefix ? attribute.prefix + ':' : '') + attribute.name] = | ||
attribute.value | ||
const name = | ||
(attribute.prefix ? attribute.prefix + ':' : '') + attribute.name | ||
if (!own.call(proto, name)) { | ||
props[name] = attribute.value | ||
} | ||
} | ||
@@ -221,0 +230,0 @@ |
{ | ||
"name": "hast-util-from-parse5", | ||
"version": "7.1.1", | ||
"version": "7.1.2", | ||
"description": "hast utility to transform from Parse5’s AST", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
24841
432
0