unified

Project: rehypejs/rehype-minify

Package: hast-util-is-javascript@1.0.4

  1. Dependencies: 3·Dependents: 8
  2. hast utility to check if an element is a JavaScript script
  1. util 118
  2. utility 114
  3. unist 110
  4. html 110
  5. hast 60
  6. hast-util 40
  7. javascript 10
  8. script 10

hast-util-is-javascript

Build Coverage Downloads Size Sponsors Backers Chat

Check if an element is a JavaScript script.

Install

npm:

npm install hast-util-is-javascript

Use

var h = require('hastscript')
var ok = require('hast-util-is-javascript')

ok(h('script')) //=> true
ok(h('script', {type: 'text/ecmascript'})) //=> true
ok(h('script', {language: 'ecmascript'})) //=> true
ok(h('script', {type: 'text/fooscript'})) //=> false
ok(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