Gathering detailed insights and metrics for hast-util-parse-selector
Gathering detailed insights and metrics for hast-util-parse-selector
Gathering detailed insights and metrics for hast-util-parse-selector
Gathering detailed insights and metrics for hast-util-parse-selector
utility to create an element from a simple CSS selector
npm install hast-util-parse-selector
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
13 Stars
105 Commits
2 Forks
9 Watching
1 Branches
11 Contributors
Updated on 18 Apr 2024
Minified
Minified + Gzipped
JavaScript (82.98%)
TypeScript (17.02%)
Cumulative downloads
Total Downloads
Last day
-0.7%
1,070,904
Compared to previous day
Last week
3.5%
5,596,213
Compared to previous week
Last month
12.9%
23,555,845
Compared to previous month
Last year
-4.4%
255,481,329
Compared to previous year
1
hast utility to create an element from a simple CSS selector.
This package is a tiny utility that helps create elements.
This utility is super niche.
You probably want the more powerful hastscript
or
hast-util-from-selector
This package is ESM only. In Node.js (version 16+), install with npm:
1npm install hast-util-parse-selector
In Deno with esm.sh
:
1import {parseSelector} from 'https://esm.sh/hast-util-parse-selector@4'
In browsers with esm.sh
:
1<script type="module"> 2 import {parseSelector} from 'https://esm.sh/hast-util-parse-selector@4?bundle' 3</script>
1import {parseSelector} from 'hast-util-parse-selector' 2 3console.log(parseSelector('.quux#bar.baz.qux'))
Yields:
1{ type: 'element', 2 tagName: 'div', 3 properties: { id: 'bar', className: [ 'quux', 'baz', 'qux' ] }, 4 children: [] }
This package exports the identifier parseSelector
.
There is no default export.
parseSelector(selector?[, defaultTagName])
Create a hast element from a simple CSS selector.
selector
(string
, optional)
— simple CSS selector, can contain a tag name (foo
), classes (.bar
),
and an ID (#baz
), multiple classes are allowed, uses the last ID if
multiple IDs are founddefaultTagName
(string
, default: 'div'
)
— tag name to use if selector
does not specify oneBuilt element (Element
).
This package is fully typed with TypeScript. It exports no additional types.
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-parse-selector@^4
, compatible with Node.js 16.
Improper use of the selector
or defaultTagName
can open you up to a
cross-site scripting (XSS) attack as the value of tagName
, when
resolving to script
, injects a script
element into the syntax tree.
Do not use user input in selector
or use
hast-util-santize
.
hast-util-from-selector
— parse complex CSS selectors to nodesSee 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 dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
Found 1/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
Project has not signed or included provenance with any releases.
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
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