hast-util-is-element

WebJar for hast-util-is-element

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

hast-util-is-element
Last Version

Last Version

1.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

hast-util-is-element
WebJar for hast-util-is-element
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/syntax-tree/hast-util-is-element

Download hast-util-is-element

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/hast-util-is-element/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>hast-util-is-element</artifactId>
    <version>1.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/hast-util-is-element/
implementation 'org.webjars.npm:hast-util-is-element:1.0.3'
// https://jarcasting.com/artifacts/org.webjars.npm/hast-util-is-element/
implementation ("org.webjars.npm:hast-util-is-element:1.0.3")
'org.webjars.npm:hast-util-is-element:jar:1.0.3'
<dependency org="org.webjars.npm" name="hast-util-is-element" rev="1.0.3">
  <artifact name="hast-util-is-element" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='hast-util-is-element', version='1.0.3')
)
libraryDependencies += "org.webjars.npm" % "hast-util-is-element" % "1.0.3"
[org.webjars.npm/hast-util-is-element "1.0.3"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

hast-util-is-element

Build Coverage Downloads Size Sponsors Backers Chat

hast utility to check if a node is a (certain) element.

Install

npm:

npm install hast-util-is-element

Use

var is = require('hast-util-is-element')

is({type: 'text', value: 'foo'}) // => false

is({type: 'element', tagName: 'a'}, 'a') // => true

is({type: 'element', tagName: 'a'}, ['a', 'area']) // => true

API

isElement(node[, test[, index, parent[, context]]])

Check if the given value is a (certain) element.

  • node (Node) — Node to check.
  • test (Function, string, or Array.<Test>, optional) — When array, checks if any one of the subtests pass. When string, checks that the element has that tag name. When function, see test
  • index (number, optional) — Index of node in parent
  • parent (Node, optional) — Parent of node
  • context (*, optional) — Context object to invoke test with
Returns

boolean — Whether test passed and node is an Element.

Throws

Error — When an incorrect test, index, or parent is given. A node that is not a node, or not an element, does not throw.

function test(element[, index, parent])

Parameters
  • element (Element) — Element to check
  • index (number?) — Index of node in parent
  • parent (Node?) — Parent of node
Context

* — The to is given context.

Returns

boolean? — Whether element matches.

isElement.convert(test)

Create a test function from test, that can later be called with a node, index, and parent. Useful if you’re going to test many nodes, for example when creating a utility where something else passes a compatible test.

The created function is slightly faster because it expects valid input only. Therefore, passing invalid input, yields unexpected results.

Can also be accessed with require('hast-util-is-element/convert').

Security

hast-util-is-element does not change the syntax tree so there are no openings for cross-site scripting (XSS) attacks.

Related

Contribute

See 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.

License

MIT © Titus Wormer

org.webjars.npm
🌲🌲🌲🌳🌲🌳🌲🌲🌲🌳🌳🌲🌲🌳🌲🌲🎄🌲🌳🌲🌲🌳🐻🌳🌳🌳🌲🌲🌳🌲🎄🌲🌳🌲🌲🌳🌳🌳

Versions

Version
1.0.3