README
hast-util-is-javascript
Check if an element is a JavaScript script.
Install
This package is ESM only:
Node 12+ is needed to use it and it must be imported
ed instead of required
d.
npm:
npm install hast-util-is-javascript
This package exports the following identifiers:
isJavaScript
.
There is no default export.
Use
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
API
isJavaScript(node)
Return true
if node
is a <script>
element that has a valid JavaScript
type
, has no type
and a valid JavaScript language
, or has neither.
Contribute
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.