$ npm i dom-nodes -Simport {isVoid} from 'dom-nodes'
isVoid('div') // false
isVoid('img') // truedom-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!
- VOID_SVG_TAGS_LIST
- HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_LIST
- SVG_TAGS_LIST
- VOID_HTML_TAGS_LIST
- HTML_TAGS_LIST
- BOOLEAN_ATTRIBUTES_LIST
- HTML_TAGS_RE
- SVG_TAGS_RE
- VOID_HTML_TAGS_RE
- VOID_SVG_TAGS_RE
- HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_RE
- BOOLEAN_ATTRIBUTES_RE
- isVoid
- isHtml
- isSvg
- isCustom
- hasValueAttribute
- isBoolAttribute
SVG void elements that cannot be auto-closed and shouldn't contain child nodes.
Type: Array
List of html elements where the value attribute is allowed
Type: Array
List of all the available svg tags
Type: Array
- See: http://www.w3.org/TR/html-markup/syntax.html#syntax-elements
- See: http://www.w3.org/TR/html5/syntax.html#void-elements
HTML void elements that cannot be auto-closed and shouldn't contain child nodes.
Type: Array
List of all the html tags
Type: Array
List of all boolean HTML attributes
Type: RegExp
Regex matching all the html tags ignoring the cases
Type: RegExp
Regex matching all the svg tags ignoring the cases
Type: RegExp
Regex matching all the void html tags ignoring the cases
Type: RegExp
Regex matching all the void svg tags ignoring the cases
Type: RegExp
Regex matching all the html tags where the value tag is allowed
Type: RegExp
Regex matching all the boolean attributes
Type: RegExp
True if it's a self closing tag
tagstring test tag
isVoid('meta') // true
isVoid('circle') // true
isVoid('IMG') // true
isVoid('div') // false
isVoid('mask') // falseReturns boolean true if void
True if it's a known HTML tag
tagstring test tag
isHtml('img') // true
isHtml('IMG') // true
isHtml('Img') // true
isHtml('path') // falseReturns boolean true if html tag
True if it's a known SVG tag
tagstring test tag
isSvg('g') // true
isSvg('radialGradient') // true
isSvg('radialgradient') // true
isSvg('div') // falseReturns boolean true if svg tag
True if it's not SVG nor a HTML known tag
tagstring test tag
isCustom('my-component') // true
isCustom('div') // falseReturns boolean true if custom element
True if the value attribute is allowed on this tag
tagstring test tag
hasValueAttribute('input') // true
hasValueAttribute('div') // falseReturns boolean true if the value attribute is allowed
True if it's a boolean attribute
attributestring test attribute
isBoolAttribute('selected') // true
isBoolAttribute('class') // falseReturns boolean true if the attribute is a boolean type