New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hast-util-to-dom

Package Overview
Dependencies
Maintainers
0
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hast-util-to-dom - npm Package Compare versions

Comparing version 4.0.0 to 4.0.1

index.d.ts.map

5

index.d.ts
export { toDom } from "./lib/index.js";
export type AfterTransform = import('./lib/index.js').AfterTransform;
export type Options = import('./lib/index.js').Options;
export type AfterTransform = import("./lib/index.js").AfterTransform;
export type Options = import("./lib/index.js").Options;
//# sourceMappingURL=index.d.ts.map

11

lib/index.d.ts

@@ -12,11 +12,2 @@ /**

export function toDom(tree: HastNodes, options?: Options | null | undefined): Comment | Document | DocumentFragment | DocumentType | Element | Text;
export type HastComment = import('hast').Comment;
export type HastDoctype = import('hast').Doctype;
export type HastElement = import('hast').Element;
export type HastNodes = import('hast').Nodes;
export type HastProperties = import('hast').Properties;
export type HastRoot = import('hast').Root;
export type HastRootContent = import('hast').RootContent;
export type HastText = import('hast').Text;
export type Schema = import('property-information').Schema;
/**

@@ -73,1 +64,3 @@ * Callback called when each node is transformed.

};
import type { Nodes as HastNodes } from 'hast';
//# sourceMappingURL=index.d.ts.map
/**
* @typedef {import('hast').Comment} HastComment
* @typedef {import('hast').Doctype} HastDoctype
* @typedef {import('hast').Element} HastElement
* @typedef {import('hast').Nodes} HastNodes
* @typedef {import('hast').Properties} HastProperties
* @typedef {import('hast').Root} HastRoot
* @typedef {import('hast').RootContent} HastRootContent
* @typedef {import('hast').Text} HastText
*
* @typedef {import('property-information').Schema} Schema
* @import {
* Comment as HastComment,
* Doctype as HastDoctype,
* Element as HastElement,
* Nodes as HastNodes,
* Properties as HastProperties,
* RootContent as HastRootContent,
* Root as HastRoot,
* Text as HastText
* } from 'hast'
* @import {Schema} from 'property-information'
*/

@@ -13,0 +14,0 @@

{
"name": "hast-util-to-dom",
"version": "4.0.0",
"description": "hast utility to transform to the DOM",
"license": "ISC",
"keywords": [
"unist",
"hast",
"hast-util",
"util",
"utility",
"rehype",
"dom",
"html"
],
"repository": "syntax-tree/hast-util-to-dom",
"author": "Keith McKnight <keith@mcknig.ht> (https://keith.mcknig.ht)",
"bugs": "https://github.com/syntax-tree/hast-util-to-dom/issues",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"author": "Keith McKnight <keith@mcknig.ht> (https://keith.mcknig.ht)",
"contributors": [

@@ -27,38 +8,46 @@ "Keith McKnight <keith@mcknig.ht> (https://keith.mcknig.ht)",

],
"sideEffects": false,
"type": "module",
"exports": "./index.js",
"files": [
"lib/",
"index.d.ts",
"index.js"
],
"dependencies": {
"@types/hast": "^3.0.0",
"property-information": "^6.0.0",
"property-information": "^7.0.0",
"web-namespaces": "^2.0.0"
},
"description": "hast utility to transform to the DOM",
"devDependencies": {
"@types/jsdom": "^21.0.0",
"@types/node": "^20.0.0",
"@types/node": "^22.0.0",
"@types/w3c-xmlserializer": "^2.0.0",
"c8": "^8.0.0",
"hastscript": "^8.0.0",
"jsdom": "^22.0.0",
"c8": "^10.0.0",
"hastscript": "^9.0.0",
"jsdom": "^26.0.0",
"prettier": "^3.0.0",
"remark-cli": "^11.0.0",
"remark-preset-wooorm": "^9.0.0",
"remark-cli": "^12.0.0",
"remark-preset-wooorm": "^11.0.0",
"type-coverage": "^2.0.0",
"typescript": "^5.0.0",
"w3c-xmlserializer": "^4.0.0",
"xo": "^0.55.0"
"w3c-xmlserializer": "^5.0.0",
"xo": "^0.60.0"
},
"scripts": {
"prepack": "npm run build && npm run format",
"build": "tsc --build --clean && tsc --build && type-coverage",
"format": "remark . -qfo && prettier . -w --log-level warn && xo --fix",
"test-api": "node --conditions development test/index.js",
"test-coverage": "c8 --100 --reporter lcov npm run test-api",
"test": "npm run build && npm run format && npm run test-coverage"
"exports": "./index.js",
"files": [
"index.d.ts.map",
"index.d.ts",
"index.js",
"lib/"
],
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"keywords": [
"dom",
"hast-util",
"hast",
"html",
"rehype",
"unist",
"utility",
"util"
],
"license": "ISC",
"name": "hast-util-to-dom",
"prettier": {

@@ -77,8 +66,17 @@ "bracketSpacing": false,

},
"repository": "syntax-tree/hast-util-to-dom",
"scripts": {
"build": "tsc --build --clean && tsc --build && type-coverage",
"format": "remark --frail --output --quiet -- . && prettier --log-level warn --write -- . && xo --fix",
"test-api": "node --conditions development test/index.js",
"test-coverage": "c8 --100 --reporter lcov -- npm run test-api",
"test": "npm run build && npm run format && npm run test-coverage"
},
"sideEffects": false,
"typeCoverage": {
"atLeast": 100,
"detail": true,
"ignoreCatch": true,
"strict": true
},
"type": "module",
"version": "4.0.1",
"xo": {

@@ -85,0 +83,0 @@ "overrides": [

# hast-util-to-dom
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]
[![Build][badge-build-image]][badge-build-url]
[![Coverage][badge-coverage-image]][badge-coverage-url]
[![Downloads][badge-downloads-image]][badge-downloads-url]
[![Size][badge-size-image]][badge-size-url]
[hast][] utility to transform to a [DOM][] tree.
[hast][github-hast] utility to transform to a [DOM][mozilla-dom] tree.
## Contents
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`toDom(tree[, options])`](#todomtree-options)
* [`AfterTransform`](#aftertransform)
* [`Options`](#options)
* [Syntax tree](#syntax-tree)
* [Types](#types)
* [Compatibility](#compatibility)
* [Security](#security)
* [Related](#related)
* [Contribute](#contribute)
* [License](#license)
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`toDom(tree[, options])`](#todomtree-options)
* [`AfterTransform`](#aftertransform)
* [`Options`](#options)
* [Syntax tree](#syntax-tree)
* [Types](#types)
* [Compatibility](#compatibility)
* [Security](#security)
* [Related](#related)
* [Contribute](#contribute)
* [License](#license)
## What is this?
This package is a utility that creates a DOM tree (defaulting to the actual DOM
but also supporting things like [`jsdom`][jsdom]) from a [hast][] (HTML) syntax
tree.
This package is a utility that creates a DOM tree
(defaulting to the actual DOM but also supporting things like
[`jsdom`][github-jsdom])
from a [hast][github-hast] (HTML) syntax tree.

@@ -40,16 +38,18 @@ ## When should I use this?

You can use this project when you want to turn hast into a DOM in browsers,
either to use it directly on a page, or to enable the use of DOM APIs (such as
`querySelector` to find things or `innerHTML` to serialize stuff).
either to use it directly on a page,
or to enable the use of DOM APIs
(such as `querySelector` to find things or `innerHTML` to serialize stuff).
The hast utility [`hast-util-from-dom`][hast-util-from-dom] does the inverse of
this utility.
The hast utility [`hast-util-from-dom`][github-hast-util-from-dom] does the
inverse of this utility.
It turns DOM trees into hast.
The rehype plugin [`rehype-dom-stringify`][rehype-dom-stringify] wraps this
utility to serialize as HTML with DOM APIs.
The rehype plugin [`rehype-dom-stringify`][github-rehype-dom-stringify] wraps
this utility to serialize as HTML with DOM APIs.
## Install
This package is [ESM only][esm].
In Node.js (version 16+), install with [npm][]:
This package is [ESM only][github-gist-esm].
In Node.js (version 16+),
install with [npm][npmjs-install]:

@@ -95,4 +95,6 @@ ```sh

Now running `open example.html` shows the `main`, `h1`, and `p` elements on the
page.
Now running `open example.html` shows the
`main`,
`h1`,
and `p` elements on the page.

@@ -110,10 +112,12 @@ ## API

* `tree` ([`HastNode`][hast-node])
— tree to transform
* `options` ([`Options`][api-options], optional)
— configuration
* `tree`
([`HastNode`][github-hast-nodes])
— tree to transform
* `options`
([`Options`][api-options], optional)
— configuration
###### Returns
DOM node ([`DomNode`][dom-node]).
DOM node ([`DomNode`][mozilla-dom-node]).

@@ -126,6 +130,6 @@ ### `AfterTransform`

* `hastNode` ([`HastNode`][hast-node])
— hast node that was handled
* `domNode` ([`DomNode`][dom-node])
— corresponding DOM node
* `hastNode` ([`HastNode`][github-hast-nodes])
— hast node that was handled
* `domNode` ([`DomNode`][mozilla-dom-node])
— corresponding DOM node

@@ -142,14 +146,18 @@ ###### Returns

* `afterTransform` ([`AfterTransform`][api-after-transform], optional)
— callback called when each node is transformed
* `document` (`Document`, default: `globalThis.document`)
— document interface to use.
* `fragment` (`boolean`, default: `false`)
— whether to return a DOM fragment (`true`) or a whole document (`false`)
* `namespace` (`string`, default: depends)
— namespace to use to create elements
* `afterTransform`
([`AfterTransform`][api-after-transform], optional)
— callback called when each node is transformed
* `document`
(`Document`, default: `globalThis.document`)
— document interface to use.
* `fragment`
(`boolean`, default: `false`)
— whether to return a DOM fragment (`true`) or a whole document (`false`)
* `namespace`
(`string`, default: depends)
— namespace to use to create elements
## Syntax tree
The syntax tree is [hast][].
The syntax tree is [hast][github-hast].

@@ -167,5 +175,6 @@ ## Types

When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line, `hast-util-to-dom@^4`,
When we cut a new major release,
we drop support for unmaintained versions of Node.
This means we try to keep the current release line,
`hast-util-to-dom@4`,
compatible with Node.js 16.

@@ -176,98 +185,92 @@

Use of `hast-util-to-dom` can open you up to a
[cross-site scripting (XSS)][xss] attack if the hast tree is unsafe.
Use [`hast-util-santize`][hast-util-sanitize] to make the hast tree safe.
[cross-site scripting (XSS)][wikipedia-xss] attack if the hast tree is unsafe.
Use [`hast-util-santize`][github-hast-util-sanitize] to make the hast tree
safe.
## Related
* [`hast-util-sanitize`](https://github.com/syntax-tree/hast-util-sanitize)
— sanitize hast nodes
* [`hast-util-to-html`](https://github.com/syntax-tree/hast-util-to-html)
— serialize as HTML
* [`hast-util-from-dom`](https://github.com/syntax-tree/hast-util-from-dom)
— create a hast tree from a DOM tree
* [`hast-util-sanitize`][github-hast-util-sanitize]
— sanitize hast nodes
* [`hast-util-to-html`](https://github.com/syntax-tree/hast-util-to-html)
— serialize as HTML
* [`hast-util-from-dom`][github-hast-util-from-dom]
— create a hast tree from a DOM tree
## Contribute
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
ways to get started.
See [`support.md`][support] for ways to get help.
See [`contributing.md`][health-contributing]
in
[`syntax-tree/.github`][health]
for ways to get started.
See [`support.md`][health-support] for ways to get help.
This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.
This project has a [code of conduct][health-coc].
By interacting with this repository,
organization,
or community you agree to abide by its terms.
## License
[ISC][license] © [Keith McKnight][author]
[ISC][file-license] © [Keith McKnight][mcknight]
<!-- Definitions -->
[build-badge]: https://github.com/syntax-tree/hast-util-to-dom/workflows/main/badge.svg
[api-after-transform]: #aftertransform
[build]: https://github.com/syntax-tree/hast-util-to-dom/actions
[api-options]: #options
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-to-dom.svg
[api-to-dom]: #todomtree-options
[coverage]: https://codecov.io/github/syntax-tree/hast-util-to-dom
[badge-build-image]: https://github.com/syntax-tree/hast-util-to-dom/workflows/main/badge.svg
[downloads-badge]: https://img.shields.io/npm/dm/hast-util-to-dom.svg
[badge-build-url]: https://github.com/syntax-tree/hast-util-to-dom/actions
[downloads]: https://www.npmjs.com/package/hast-util-to-dom
[badge-coverage-image]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-to-dom.svg
[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=hast-util-to-dom
[badge-coverage-url]: https://codecov.io/github/syntax-tree/hast-util-to-dom
[size]: https://bundlejs.com/?q=hast-util-to-dom
[badge-downloads-image]: https://img.shields.io/npm/dm/hast-util-to-dom.svg
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[badge-downloads-url]: https://www.npmjs.com/package/hast-util-to-dom
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[badge-size-image]: https://img.shields.io/bundlejs/size/hast-util-to-dom
[collective]: https://opencollective.com/unified
[badge-size-url]: https://bundlejs.com/?q=hast-util-to-dom
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[chat]: https://github.com/syntax-tree/unist/discussions
[npm]: https://docs.npmjs.com/cli/install
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[esmsh]: https://esm.sh
[typescript]: https://www.typescriptlang.org
[file-license]: license
[license]: license
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[author]: https://keith.mcknig.ht
[github-hast]: https://github.com/syntax-tree/hast
[health]: https://github.com/syntax-tree/.github
[github-hast-nodes]: https://github.com/syntax-tree/hast#nodes
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
[github-hast-util-from-dom]: https://github.com/syntax-tree/hast-util-from-dom
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
[github-hast-util-sanitize]: https://github.com/syntax-tree/hast-util-sanitize
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
[github-jsdom]: https://github.com/jsdom/jsdom
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
[github-rehype-dom-stringify]: https://github.com/rehypejs/rehype-dom/tree/main/packages/rehype-dom-stringify
[hast-util-sanitize]: https://github.com/syntax-tree/hast-util-sanitize
[health]: https://github.com/syntax-tree/.github
[hast-util-from-dom]: https://github.com/syntax-tree/hast-util-from-dom
[health-coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
[jsdom]: https://github.com/jsdom/jsdom
[health-contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
[rehype-dom-stringify]: https://github.com/rehypejs/rehype-dom/tree/main/packages/rehype-dom-stringify
[health-support]: https://github.com/syntax-tree/.github/blob/main/support.md
[hast]: https://github.com/syntax-tree/hast
[mcknight]: https://keith.mcknig.ht
[hast-node]: https://github.com/syntax-tree/hast#nodes
[mozilla-dom]: https://developer.mozilla.org/docs/Web/API/Document_Object_Model
[dom]: https://developer.mozilla.org/docs/Web/API/Document_Object_Model
[mozilla-dom-node]: https://developer.mozilla.org/docs/Web/API/Node
[dom-node]: https://developer.mozilla.org/docs/Web/API/Node
[npmjs-install]: https://docs.npmjs.com/cli/install
[api-to-dom]: #todomtree-options
[typescript]: https://www.typescriptlang.org
[api-after-transform]: #aftertransform
[api-options]: #options
[wikipedia-xss]: https://en.wikipedia.org/wiki/Cross-site_scripting

Sorry, the diff of this file is not supported yet

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