Gathering detailed insights and metrics for hast-util-to-dom
Gathering detailed insights and metrics for hast-util-to-dom
Gathering detailed insights and metrics for hast-util-to-dom
Gathering detailed insights and metrics for hast-util-to-dom
npm install hast-util-to-dom
Typescript
Module System
Node Version
NPM Version
93.2
Supply Chain
99.5
Quality
79
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
ISC License
20 Stars
105 Commits
8 Forks
8 Watchers
1 Branches
12 Contributors
Updated on Feb 19, 2025
Latest Version
4.0.1
Package Id
hast-util-to-dom@4.0.1
Unpacked Size
21.21 kB
Size
6.70 kB
File Count
9
NPM Version
11.1.0
Node Version
23.1.0
Published on
Feb 19, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
hast utility to transform to a DOM tree.
This package is a utility that creates a DOM tree
(defaulting to the actual DOM but also supporting things like
jsdom
)
from a hast (HTML) syntax tree.
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).
The hast utility hast-util-from-dom
does the
inverse of this utility.
It turns DOM trees into hast.
The rehype plugin rehype-dom-stringify
wraps
this utility to serialize as HTML with DOM APIs.
This package is ESM only. In Node.js (version 16+), install with npm:
1npm install hast-util-to-dom
In Deno with esm.sh
:
1import {toDom} from 'https://esm.sh/hast-util-to-dom@4'
In browsers with esm.sh
:
1<script type="module"> 2 import {toDom} from 'https://esm.sh/hast-util-to-dom@4?bundle' 3</script>
Say our page example.html
looks as follows:
1<!doctype html> 2<title>Example</title> 3<body> 4 <script type="module"> 5 import {h} from 'https://esm.sh/hastscript?bundle' 6 import {toDom} from 'https://esm.sh/hast-util-to-dom?bundle' 7 8 const tree = h('main', [ 9 h('h1', 'Hi'), 10 h('p', [h('em', 'Hello'), ', world!']) 11 ]) 12 13 document.body.append(toDom(tree)) 14 </script>
Now running open example.html
shows the
main
,
h1
,
and p
elements on the page.
This package exports the identifier toDom
.
There is no default export.
toDom(tree[, options])
Turn a hast tree into a DOM tree.
DOM node (DomNode
).
AfterTransform
Callback called when each node is transformed (TypeScript type).
Nothing.
Options
Configuration (TypeScript type).
afterTransform
(AfterTransform
, optional)
— callback called when each node is transformeddocument
(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 elementsThe syntax tree is hast.
This package is fully typed with TypeScript.
It exports the additional types AfterTransform
and
Options
.
Projects maintained by the unified collective are compatible with maintained versions of Node.js.
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.
Use of hast-util-to-dom
can open you up to a
cross-site scripting (XSS) attack if the hast tree is unsafe.
Use hast-util-santize
to make the hast tree
safe.
hast-util-sanitize
— sanitize hast nodeshast-util-to-html
— serialize as HTMLhast-util-from-dom
— create a hast tree from a DOM treeSee contributing.md
in
syntax-tree/.github
for ways to get started.
See support.md
for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More