hast-util-is-javascript

hast utility to check if an element is a JavaScript script

Usage no npm install needed!

<script type="module">
  import hastUtilIsJavascript from 'https://cdn.skypack.dev/hast-util-is-javascript';
</script>

README

hast-util-is-javascript

Build Coverage Downloads Size Sponsors Backers Chat

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 importeded instead of requiredd.

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.

License

MIT © Titus Wormer