riot/dom-nodes

Name: dom-nodes

Owner: Riot

Description: List of all the available DOM and SVG nodes and helper functions to quickly test against them

Created: 2018-02-10 15:44:50.0

Updated: 2018-04-16 03:03:36.0

Pushed: 2018-02-11 20:42:48.0

Homepage: null

Size: 18

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

dom-nodes

Build Status

NPM version NPM downloads MIT License

Installation
m i dom-nodes -S
Usage
rt {isVoid} from 'dom-nodes'
id('div') // false
id('img') // true

dom-nodes exports all the methods listed below giving you some simple tests to understand which kind of node you are dealing with.

This project includes html-tags and svg-tag-names directly in its source code avoiding to rely on third party npm modules for such simple list of strings. This project couldn't have been made without the projects above!

API
Table of Contents
VOID_SVG_TAGS_LIST

SVG void elements that cannot be auto-closed and shouldn't contain child nodes.

Type: Array

SVG_TAGS_LIST

List of all the available svg tags

Type: Array

VOID_HTML_TAGS_LIST

HTML void elements that cannot be auto-closed and shouldn't contain child nodes.

HTML_TAGS_LIST

List of all the html tags

Type: Array

BOOLEAN_ATTRIBUTES_LIST

List of all boolean HTML attributes

Type: RegExp

HTML_TAGS_RE

Regex matching all the html tags ignoring the cases

Type: RegExp

SVG_TAGS_RE

Regex matching all the svg tags ignoring the cases

Type: RegExp

VOID_HTML_TAGS_RE

Regex matching all the void html tags ignoring the cases

Type: RegExp

VOID_SVG_TAGS_RE

Regex matching all the void svg tags ignoring the cases

Type: RegExp

BOOLEAN_ATTRIBUTES_RE

Regex matching all the boolean attributes

Type: RegExp

isVoid

True if it's a self closing tag

Parameters

Examples

id('meta') // true
id('circle') // true
id('IMG') // true
id('div') // false
id('mask') // false

Returns Boolean

isHtml

True if it's a known HTML tag

Parameters

Examples

ml('img') // true
ml('IMG') // true
ml('Img') // true
ml('path') // false

Returns Boolean

isSvg

True if it's a known SVG tag

Parameters

Examples

g('g') // true
g('radialGradient') // true
g('radialgradient') // true
g('div') // false

Returns Boolean

isCustom

True if it's not SVG nor a HTML known tag

Parameters

Examples

stom('my-component') // true
stom('div') // false

Returns Boolean

isBoolAttribute

True if it's a boolean attribute

Parameters

Examples

olAttribute('selected') // true
olAttribute('class') // false

Returns Boolean


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.