Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
hast-util-is-javascript
Advanced tools
hast utility to check if an element is a JavaScript script
hast
utility to check if an element is a JavaScript script.
This package is a utility to check whether a hast node is a <script>
that
contains or references JavaScript.
You can use this package to check whether <script>
elements contain or
reference JavaScript or something else.
This package is ESM only. In Node.js (version 16+), install with npm:
npm install hast-util-is-javascript
In Deno with esm.sh
:
import {isJavaScript} from 'https://esm.sh/hast-util-is-javascript@3'
In browsers with esm.sh
:
<script type="module">
import {isJavaScript} from 'https://esm.sh/hast-util-is-javascript@3?bundle'
</script>
import {h} from 'hastscript'
import {isJavaScript} from 'hast-util-is-javascript'
isJavaScript(h('script')) //=> true
isJavaScript(h('script', {type: 'text/ecmascript'})) //=> true
isJavaScript(h('script', {language: 'ecmascript'})) //=> true
isJavaScript(h('script', {type: 'text/fooscript'})) //=> false
isJavaScript(h('script', {language: 'fooscript'})) //=> false
This package exports the identifier
isJavaScript
.
There is no default export.
isJavaScript(node)
Check if a node is a <script>
that contains or references JavaScript.
Returns true
if node
is a <script>
element that has a valid JavaScript
type
, has no type
and a valid JavaScript language
, or has neither.
node
(Node
) — node to checkWhether a node is a <script>
that contains or references JavaScript
(boolean
).
HTML is parsed according to WHATWG HTML (the living standard), which is also followed by all browsers.
The syntax tree used is hast.
This package is fully typed with TypeScript.
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-is-javascript@^3
,
compatible with Node.js 16.
As rehype works on HTML and improper use of HTML can open you up to a
cross-site scripting (XSS) attack, use of rehype can also be unsafe.
Use rehype-sanitize
to make the tree safe.
See contributing.md
in rehypejs/.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.
FAQs
hast utility to check if an element is a JavaScript script
The npm package hast-util-is-javascript receives a total of 18,512 weekly downloads. As such, hast-util-is-javascript popularity was classified as popular.
We found that hast-util-is-javascript demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.