$
This commit is contained in:
21
node_modules/dom-nodes/LICENSE
generated
vendored
Normal file
21
node_modules/dom-nodes/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Gianluca Guarini
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
267
node_modules/dom-nodes/README.md
generated
vendored
Normal file
267
node_modules/dom-nodes/README.md
generated
vendored
Normal file
@@ -0,0 +1,267 @@
|
||||
# dom-nodes
|
||||
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
|
||||
[![NPM version][npm-version-image]][npm-url]
|
||||
[![NPM downloads][npm-downloads-image]][npm-url]
|
||||
[![MIT License][license-image]][license-url]
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm i dom-nodes -S
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import {isVoid} from 'dom-nodes'
|
||||
isVoid('div') // false
|
||||
isVoid('img') // true
|
||||
```
|
||||
|
||||
`dom-nodes` exports all the methods [listed below](#API) giving you some simple tests to understand which kind of node you are dealing with.
|
||||
|
||||
This project includes [html-tags](https://github.com/sindresorhus/html-tags) and [svg-tag-names](https://github.com/wooorm/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!
|
||||
|
||||
[travis-image]: https://img.shields.io/travis/riot/dom-nodes.svg?style=flat-square
|
||||
|
||||
[travis-url]: https://travis-ci.org/riot/dom-nodes
|
||||
|
||||
[license-image]: http://img.shields.io/badge/license-MIT-000000.svg?style=flat-square
|
||||
|
||||
[license-url]: LICENSE
|
||||
|
||||
[npm-version-image]: http://img.shields.io/npm/v/dom-nodes.svg?style=flat-square
|
||||
|
||||
[npm-downloads-image]: http://img.shields.io/npm/dm/dom-nodes.svg?style=flat-square
|
||||
|
||||
[npm-url]: https://npmjs.org/package/dom-nodes
|
||||
|
||||
## API
|
||||
|
||||
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
||||
|
||||
#### Table of Contents
|
||||
|
||||
- [VOID_SVG_TAGS_LIST](#void_svg_tags_list)
|
||||
- [HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_LIST](#html_elements_having_value_attribute_list)
|
||||
- [SVG_TAGS_LIST](#svg_tags_list)
|
||||
- [VOID_HTML_TAGS_LIST](#void_html_tags_list)
|
||||
- [HTML_TAGS_LIST](#html_tags_list)
|
||||
- [BOOLEAN_ATTRIBUTES_LIST](#boolean_attributes_list)
|
||||
- [HTML_TAGS_RE](#html_tags_re)
|
||||
- [SVG_TAGS_RE](#svg_tags_re)
|
||||
- [VOID_HTML_TAGS_RE](#void_html_tags_re)
|
||||
- [VOID_SVG_TAGS_RE](#void_svg_tags_re)
|
||||
- [HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_RE](#html_elements_having_value_attribute_re)
|
||||
- [BOOLEAN_ATTRIBUTES_RE](#boolean_attributes_re)
|
||||
- [isVoid](#isvoid)
|
||||
- [Parameters](#parameters)
|
||||
- [Examples](#examples)
|
||||
- [isHtml](#ishtml)
|
||||
- [Parameters](#parameters-1)
|
||||
- [Examples](#examples-1)
|
||||
- [isSvg](#issvg)
|
||||
- [Parameters](#parameters-2)
|
||||
- [Examples](#examples-2)
|
||||
- [isCustom](#iscustom)
|
||||
- [Parameters](#parameters-3)
|
||||
- [Examples](#examples-3)
|
||||
- [hasValueAttribute](#hasvalueattribute)
|
||||
- [Parameters](#parameters-4)
|
||||
- [Examples](#examples-4)
|
||||
- [isBoolAttribute](#isboolattribute)
|
||||
- [Parameters](#parameters-5)
|
||||
- [Examples](#examples-5)
|
||||
|
||||
### VOID_SVG_TAGS_LIST
|
||||
|
||||
SVG void elements that cannot be auto-closed and shouldn't contain child nodes.
|
||||
|
||||
Type: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)
|
||||
|
||||
### HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_LIST
|
||||
|
||||
List of html elements where the value attribute is allowed
|
||||
|
||||
Type: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)
|
||||
|
||||
### SVG_TAGS_LIST
|
||||
|
||||
- **See: <https://github.com/wooorm/svg-tag-names>**
|
||||
|
||||
List of all the available svg tags
|
||||
|
||||
Type: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)
|
||||
|
||||
### VOID_HTML_TAGS_LIST
|
||||
|
||||
- **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](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)
|
||||
|
||||
### HTML_TAGS_LIST
|
||||
|
||||
- **See: <https://github.com/sindresorhus/html-tags>**
|
||||
|
||||
List of all the html tags
|
||||
|
||||
Type: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)
|
||||
|
||||
### BOOLEAN_ATTRIBUTES_LIST
|
||||
|
||||
- **See: <https://www.w3.org/TR/html5/infrastructure.html#sec-boolean-attributes>**
|
||||
|
||||
List of all boolean HTML attributes
|
||||
|
||||
Type: [RegExp](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp)
|
||||
|
||||
### HTML_TAGS_RE
|
||||
|
||||
Regex matching all the html tags ignoring the cases
|
||||
|
||||
Type: [RegExp](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp)
|
||||
|
||||
### SVG_TAGS_RE
|
||||
|
||||
Regex matching all the svg tags ignoring the cases
|
||||
|
||||
Type: [RegExp](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp)
|
||||
|
||||
### VOID_HTML_TAGS_RE
|
||||
|
||||
Regex matching all the void html tags ignoring the cases
|
||||
|
||||
Type: [RegExp](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp)
|
||||
|
||||
### VOID_SVG_TAGS_RE
|
||||
|
||||
Regex matching all the void svg tags ignoring the cases
|
||||
|
||||
Type: [RegExp](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp)
|
||||
|
||||
### HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_RE
|
||||
|
||||
Regex matching all the html tags where the value tag is allowed
|
||||
|
||||
Type: [RegExp](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp)
|
||||
|
||||
### BOOLEAN_ATTRIBUTES_RE
|
||||
|
||||
Regex matching all the boolean attributes
|
||||
|
||||
Type: [RegExp](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp)
|
||||
|
||||
### isVoid
|
||||
|
||||
True if it's a self closing tag
|
||||
|
||||
#### Parameters
|
||||
|
||||
- `tag` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** test tag
|
||||
|
||||
#### Examples
|
||||
|
||||
```javascript
|
||||
isVoid('meta') // true
|
||||
isVoid('circle') // true
|
||||
isVoid('IMG') // true
|
||||
isVoid('div') // false
|
||||
isVoid('mask') // false
|
||||
```
|
||||
|
||||
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if void
|
||||
|
||||
### isHtml
|
||||
|
||||
True if it's a known HTML tag
|
||||
|
||||
#### Parameters
|
||||
|
||||
- `tag` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** test tag
|
||||
|
||||
#### Examples
|
||||
|
||||
```javascript
|
||||
isHtml('img') // true
|
||||
isHtml('IMG') // true
|
||||
isHtml('Img') // true
|
||||
isHtml('path') // false
|
||||
```
|
||||
|
||||
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if html tag
|
||||
|
||||
### isSvg
|
||||
|
||||
True if it's a known SVG tag
|
||||
|
||||
#### Parameters
|
||||
|
||||
- `tag` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** test tag
|
||||
|
||||
#### Examples
|
||||
|
||||
```javascript
|
||||
isSvg('g') // true
|
||||
isSvg('radialGradient') // true
|
||||
isSvg('radialgradient') // true
|
||||
isSvg('div') // false
|
||||
```
|
||||
|
||||
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if svg tag
|
||||
|
||||
### isCustom
|
||||
|
||||
True if it's not SVG nor a HTML known tag
|
||||
|
||||
#### Parameters
|
||||
|
||||
- `tag` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** test tag
|
||||
|
||||
#### Examples
|
||||
|
||||
```javascript
|
||||
isCustom('my-component') // true
|
||||
isCustom('div') // false
|
||||
```
|
||||
|
||||
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if custom element
|
||||
|
||||
### hasValueAttribute
|
||||
|
||||
True if the value attribute is allowed on this tag
|
||||
|
||||
#### Parameters
|
||||
|
||||
- `tag` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** test tag
|
||||
|
||||
#### Examples
|
||||
|
||||
```javascript
|
||||
hasValueAttribute('input') // true
|
||||
hasValueAttribute('div') // false
|
||||
```
|
||||
|
||||
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if the value attribute is allowed
|
||||
|
||||
### isBoolAttribute
|
||||
|
||||
True if it's a boolean attribute
|
||||
|
||||
#### Parameters
|
||||
|
||||
- `attribute` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** test attribute
|
||||
|
||||
#### Examples
|
||||
|
||||
```javascript
|
||||
isBoolAttribute('selected') // true
|
||||
isBoolAttribute('class') // false
|
||||
```
|
||||
|
||||
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if the attribute is a boolean type
|
473
node_modules/dom-nodes/dom-nodes.js
generated
vendored
Normal file
473
node_modules/dom-nodes/dom-nodes.js
generated
vendored
Normal file
@@ -0,0 +1,473 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = global || self, factory(global.domNodes = {}));
|
||||
}(this, function (exports) { 'use strict';
|
||||
|
||||
// similar to _.uniq
|
||||
const uniq = l => l.filter((x, i, a) => a.indexOf(x) === i);
|
||||
|
||||
/**
|
||||
* SVG void elements that cannot be auto-closed and shouldn't contain child nodes.
|
||||
* @const {Array}
|
||||
*/
|
||||
const VOID_SVG_TAGS_LIST = [
|
||||
'circle',
|
||||
'ellipse',
|
||||
'line',
|
||||
'path',
|
||||
'polygon',
|
||||
'polyline',
|
||||
'rect',
|
||||
'stop',
|
||||
'use'
|
||||
];
|
||||
|
||||
/**
|
||||
* List of html elements where the value attribute is allowed
|
||||
* @type {Array}
|
||||
*/
|
||||
const HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_LIST = [
|
||||
'button',
|
||||
'data',
|
||||
'input',
|
||||
'select',
|
||||
'li',
|
||||
'meter',
|
||||
'option',
|
||||
'output',
|
||||
'progress',
|
||||
'textarea',
|
||||
'param'
|
||||
];
|
||||
|
||||
/**
|
||||
* List of all the available svg tags
|
||||
* @const {Array}
|
||||
* @see {@link https://github.com/wooorm/svg-tag-names}
|
||||
*/
|
||||
const SVG_TAGS_LIST = uniq([
|
||||
'a',
|
||||
'altGlyph',
|
||||
'altGlyphDef',
|
||||
'altGlyphItem',
|
||||
'animate',
|
||||
'animateColor',
|
||||
'animateMotion',
|
||||
'animateTransform',
|
||||
'animation',
|
||||
'audio',
|
||||
'canvas',
|
||||
'clipPath',
|
||||
'color-profile',
|
||||
'cursor',
|
||||
'defs',
|
||||
'desc',
|
||||
'discard',
|
||||
'feBlend',
|
||||
'feColorMatrix',
|
||||
'feComponentTransfer',
|
||||
'feComposite',
|
||||
'feConvolveMatrix',
|
||||
'feDiffuseLighting',
|
||||
'feDisplacementMap',
|
||||
'feDistantLight',
|
||||
'feDropShadow',
|
||||
'feFlood',
|
||||
'feFuncA',
|
||||
'feFuncB',
|
||||
'feFuncG',
|
||||
'feFuncR',
|
||||
'feGaussianBlur',
|
||||
'feImage',
|
||||
'feMerge',
|
||||
'feMergeNode',
|
||||
'feMorphology',
|
||||
'feOffset',
|
||||
'fePointLight',
|
||||
'feSpecularLighting',
|
||||
'feSpotLight',
|
||||
'feTile',
|
||||
'feTurbulence',
|
||||
'filter',
|
||||
'font',
|
||||
'font-face',
|
||||
'font-face-format',
|
||||
'font-face-name',
|
||||
'font-face-src',
|
||||
'font-face-uri',
|
||||
'foreignObject',
|
||||
'g',
|
||||
'glyph',
|
||||
'glyphRef',
|
||||
'handler',
|
||||
'hatch',
|
||||
'hatchpath',
|
||||
'hkern',
|
||||
'iframe',
|
||||
'image',
|
||||
'linearGradient',
|
||||
'listener',
|
||||
'marker',
|
||||
'mask',
|
||||
'mesh',
|
||||
'meshgradient',
|
||||
'meshpatch',
|
||||
'meshrow',
|
||||
'metadata',
|
||||
'missing-glyph',
|
||||
'mpath',
|
||||
'pattern',
|
||||
'prefetch',
|
||||
'radialGradient',
|
||||
'script',
|
||||
'set',
|
||||
'solidColor',
|
||||
'solidcolor',
|
||||
'style',
|
||||
'svg',
|
||||
'switch',
|
||||
'symbol',
|
||||
'tbreak',
|
||||
'text',
|
||||
'textArea',
|
||||
'textPath',
|
||||
'title',
|
||||
'tref',
|
||||
'tspan',
|
||||
'unknown',
|
||||
'video',
|
||||
'view',
|
||||
'vkern'
|
||||
].concat(VOID_SVG_TAGS_LIST)).sort();
|
||||
|
||||
/**
|
||||
* HTML void elements that cannot be auto-closed and shouldn't contain child nodes.
|
||||
* @type {Array}
|
||||
* @see {@link http://www.w3.org/TR/html-markup/syntax.html#syntax-elements}
|
||||
* @see {@link http://www.w3.org/TR/html5/syntax.html#void-elements}
|
||||
*/
|
||||
const VOID_HTML_TAGS_LIST = [
|
||||
'area',
|
||||
'base',
|
||||
'br',
|
||||
'col',
|
||||
'embed',
|
||||
'hr',
|
||||
'img',
|
||||
'input',
|
||||
'keygen',
|
||||
'link',
|
||||
'menuitem',
|
||||
'meta',
|
||||
'param',
|
||||
'source',
|
||||
'track',
|
||||
'wbr'
|
||||
];
|
||||
|
||||
/**
|
||||
* List of all the html tags
|
||||
* @const {Array}
|
||||
* @see {@link https://github.com/sindresorhus/html-tags}
|
||||
*/
|
||||
const HTML_TAGS_LIST = uniq([
|
||||
'a',
|
||||
'abbr',
|
||||
'address',
|
||||
'article',
|
||||
'aside',
|
||||
'audio',
|
||||
'b',
|
||||
'bdi',
|
||||
'bdo',
|
||||
'blockquote',
|
||||
'body',
|
||||
'canvas',
|
||||
'caption',
|
||||
'cite',
|
||||
'code',
|
||||
'colgroup',
|
||||
'datalist',
|
||||
'dd',
|
||||
'del',
|
||||
'details',
|
||||
'dfn',
|
||||
'dialog',
|
||||
'div',
|
||||
'dl',
|
||||
'dt',
|
||||
'em',
|
||||
'fieldset',
|
||||
'figcaption',
|
||||
'figure',
|
||||
'footer',
|
||||
'form',
|
||||
'h1',
|
||||
'h2',
|
||||
'h3',
|
||||
'h4',
|
||||
'h5',
|
||||
'h6',
|
||||
'head',
|
||||
'header',
|
||||
'hgroup',
|
||||
'html',
|
||||
'i',
|
||||
'iframe',
|
||||
'ins',
|
||||
'kbd',
|
||||
'label',
|
||||
'legend',
|
||||
'main',
|
||||
'map',
|
||||
'mark',
|
||||
'math',
|
||||
'menu',
|
||||
'nav',
|
||||
'noscript',
|
||||
'object',
|
||||
'ol',
|
||||
'optgroup',
|
||||
'p',
|
||||
'picture',
|
||||
'pre',
|
||||
'q',
|
||||
'rb',
|
||||
'rp',
|
||||
'rt',
|
||||
'rtc',
|
||||
'ruby',
|
||||
's',
|
||||
'samp',
|
||||
'script',
|
||||
'section',
|
||||
'select',
|
||||
'slot',
|
||||
'small',
|
||||
'span',
|
||||
'strong',
|
||||
'style',
|
||||
'sub',
|
||||
'summary',
|
||||
'sup',
|
||||
'svg',
|
||||
'table',
|
||||
'tbody',
|
||||
'td',
|
||||
'template',
|
||||
'tfoot',
|
||||
'th',
|
||||
'thead',
|
||||
'time',
|
||||
'title',
|
||||
'tr',
|
||||
'u',
|
||||
'ul',
|
||||
'var',
|
||||
'video'
|
||||
]
|
||||
.concat(VOID_HTML_TAGS_LIST)
|
||||
.concat(HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_LIST)
|
||||
).sort();
|
||||
|
||||
/**
|
||||
* List of all boolean HTML attributes
|
||||
* @const {RegExp}
|
||||
* @see {@link https://www.w3.org/TR/html5/infrastructure.html#sec-boolean-attributes}
|
||||
*/
|
||||
const BOOLEAN_ATTRIBUTES_LIST = [
|
||||
'disabled',
|
||||
'visible',
|
||||
'checked',
|
||||
'readonly',
|
||||
'required',
|
||||
'allowfullscreen',
|
||||
'autofocus',
|
||||
'autoplay',
|
||||
'compact',
|
||||
'controls',
|
||||
'default',
|
||||
'formnovalidate',
|
||||
'hidden',
|
||||
'ismap',
|
||||
'itemscope',
|
||||
'loop',
|
||||
'multiple',
|
||||
'muted',
|
||||
'noresize',
|
||||
'noshade',
|
||||
'novalidate',
|
||||
'nowrap',
|
||||
'open',
|
||||
'reversed',
|
||||
'seamless',
|
||||
'selected',
|
||||
'sortable',
|
||||
'truespeed',
|
||||
'typemustmatch'
|
||||
];
|
||||
|
||||
/**
|
||||
* Join a list of items with the pipe symbol (usefull for regex list concatenation)
|
||||
* @private
|
||||
* @param {Array} list - list of strings
|
||||
* @returns {string} the list received joined with pipes
|
||||
*/
|
||||
function joinWithPipe(list) {
|
||||
return list.join('|')
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert list of strings to regex in order to test against it ignoring the cases
|
||||
* @private
|
||||
* @param {...Array} lists - array of strings
|
||||
* @returns {RegExp} regex that will match all the strings in the array received ignoring the cases
|
||||
*/
|
||||
function listsToRegex(...lists) {
|
||||
return new RegExp(`^/?(?:${joinWithPipe(lists.map(joinWithPipe))})$`, 'i')
|
||||
}
|
||||
|
||||
/**
|
||||
* Regex matching all the html tags ignoring the cases
|
||||
* @const {RegExp}
|
||||
*/
|
||||
const HTML_TAGS_RE = listsToRegex(HTML_TAGS_LIST);
|
||||
|
||||
/**
|
||||
* Regex matching all the svg tags ignoring the cases
|
||||
* @const {RegExp}
|
||||
*/
|
||||
const SVG_TAGS_RE = listsToRegex(SVG_TAGS_LIST);
|
||||
|
||||
/**
|
||||
* Regex matching all the void html tags ignoring the cases
|
||||
* @const {RegExp}
|
||||
*/
|
||||
const VOID_HTML_TAGS_RE = listsToRegex(VOID_HTML_TAGS_LIST);
|
||||
|
||||
/**
|
||||
* Regex matching all the void svg tags ignoring the cases
|
||||
* @const {RegExp}
|
||||
*/
|
||||
const VOID_SVG_TAGS_RE = listsToRegex(VOID_SVG_TAGS_LIST);
|
||||
|
||||
/**
|
||||
* Regex matching all the html tags where the value tag is allowed
|
||||
* @const {RegExp}
|
||||
*/
|
||||
const HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_RE = listsToRegex(HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_LIST);
|
||||
|
||||
/**
|
||||
* Regex matching all the boolean attributes
|
||||
* @const {RegExp}
|
||||
*/
|
||||
const BOOLEAN_ATTRIBUTES_RE = listsToRegex(BOOLEAN_ATTRIBUTES_LIST);
|
||||
|
||||
/**
|
||||
* True if it's a self closing tag
|
||||
* @param {string} tag - test tag
|
||||
* @returns {boolean} true if void
|
||||
* @example
|
||||
* isVoid('meta') // true
|
||||
* isVoid('circle') // true
|
||||
* isVoid('IMG') // true
|
||||
* isVoid('div') // false
|
||||
* isVoid('mask') // false
|
||||
*/
|
||||
function isVoid(tag) {
|
||||
return [
|
||||
VOID_HTML_TAGS_RE,
|
||||
VOID_SVG_TAGS_RE
|
||||
].some(r => r.test(tag))
|
||||
}
|
||||
|
||||
/**
|
||||
* True if it's a known HTML tag
|
||||
* @param {string} tag - test tag
|
||||
* @returns {boolean} true if html tag
|
||||
* @example
|
||||
* isHtml('img') // true
|
||||
* isHtml('IMG') // true
|
||||
* isHtml('Img') // true
|
||||
* isHtml('path') // false
|
||||
*/
|
||||
function isHtml(tag) {
|
||||
return HTML_TAGS_RE.test(tag)
|
||||
}
|
||||
|
||||
/**
|
||||
* True if it's a known SVG tag
|
||||
* @param {string} tag - test tag
|
||||
* @returns {boolean} true if svg tag
|
||||
* @example
|
||||
* isSvg('g') // true
|
||||
* isSvg('radialGradient') // true
|
||||
* isSvg('radialgradient') // true
|
||||
* isSvg('div') // false
|
||||
*/
|
||||
function isSvg(tag) {
|
||||
return SVG_TAGS_RE.test(tag)
|
||||
}
|
||||
|
||||
/**
|
||||
* True if it's not SVG nor a HTML known tag
|
||||
* @param {string} tag - test tag
|
||||
* @returns {boolean} true if custom element
|
||||
* @example
|
||||
* isCustom('my-component') // true
|
||||
* isCustom('div') // false
|
||||
*/
|
||||
function isCustom(tag) {
|
||||
return [
|
||||
HTML_TAGS_RE,
|
||||
SVG_TAGS_RE
|
||||
].every(l => !l.test(tag))
|
||||
}
|
||||
|
||||
/**
|
||||
* True if the value attribute is allowed on this tag
|
||||
* @param {string} tag - test tag
|
||||
* @returns {boolean} true if the value attribute is allowed
|
||||
* @example
|
||||
* hasValueAttribute('input') // true
|
||||
* hasValueAttribute('div') // false
|
||||
*/
|
||||
function hasValueAttribute(tag) {
|
||||
return HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_RE.test(tag)
|
||||
}
|
||||
|
||||
/**
|
||||
* True if it's a boolean attribute
|
||||
* @param {string} attribute - test attribute
|
||||
* @returns {boolean} true if the attribute is a boolean type
|
||||
* @example
|
||||
* isBoolAttribute('selected') // true
|
||||
* isBoolAttribute('class') // false
|
||||
*/
|
||||
function isBoolAttribute(attribute) {
|
||||
return BOOLEAN_ATTRIBUTES_RE.test(attribute)
|
||||
}
|
||||
|
||||
exports.BOOLEAN_ATTRIBUTES_LIST = BOOLEAN_ATTRIBUTES_LIST;
|
||||
exports.BOOLEAN_ATTRIBUTES_RE = BOOLEAN_ATTRIBUTES_RE;
|
||||
exports.HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_LIST = HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_LIST;
|
||||
exports.HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_RE = HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_RE;
|
||||
exports.HTML_TAGS_LIST = HTML_TAGS_LIST;
|
||||
exports.HTML_TAGS_RE = HTML_TAGS_RE;
|
||||
exports.SVG_TAGS_LIST = SVG_TAGS_LIST;
|
||||
exports.SVG_TAGS_RE = SVG_TAGS_RE;
|
||||
exports.VOID_HTML_TAGS_LIST = VOID_HTML_TAGS_LIST;
|
||||
exports.VOID_HTML_TAGS_RE = VOID_HTML_TAGS_RE;
|
||||
exports.VOID_SVG_TAGS_LIST = VOID_SVG_TAGS_LIST;
|
||||
exports.VOID_SVG_TAGS_RE = VOID_SVG_TAGS_RE;
|
||||
exports.hasValueAttribute = hasValueAttribute;
|
||||
exports.isBoolAttribute = isBoolAttribute;
|
||||
exports.isCustom = isCustom;
|
||||
exports.isHtml = isHtml;
|
||||
exports.isSvg = isSvg;
|
||||
exports.isVoid = isVoid;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
}));
|
444
node_modules/dom-nodes/index.next.js
generated
vendored
Normal file
444
node_modules/dom-nodes/index.next.js
generated
vendored
Normal file
@@ -0,0 +1,444 @@
|
||||
// similar to _.uniq
|
||||
const uniq = l => l.filter((x, i, a) => a.indexOf(x) === i)
|
||||
|
||||
/**
|
||||
* SVG void elements that cannot be auto-closed and shouldn't contain child nodes.
|
||||
* @const {Array}
|
||||
*/
|
||||
export const VOID_SVG_TAGS_LIST = [
|
||||
'circle',
|
||||
'ellipse',
|
||||
'line',
|
||||
'path',
|
||||
'polygon',
|
||||
'polyline',
|
||||
'rect',
|
||||
'stop',
|
||||
'use'
|
||||
]
|
||||
|
||||
/**
|
||||
* List of html elements where the value attribute is allowed
|
||||
* @type {Array}
|
||||
*/
|
||||
export const HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_LIST = [
|
||||
'button',
|
||||
'data',
|
||||
'input',
|
||||
'select',
|
||||
'li',
|
||||
'meter',
|
||||
'option',
|
||||
'output',
|
||||
'progress',
|
||||
'textarea',
|
||||
'param'
|
||||
]
|
||||
|
||||
/**
|
||||
* List of all the available svg tags
|
||||
* @const {Array}
|
||||
* @see {@link https://github.com/wooorm/svg-tag-names}
|
||||
*/
|
||||
export const SVG_TAGS_LIST = uniq([
|
||||
'a',
|
||||
'altGlyph',
|
||||
'altGlyphDef',
|
||||
'altGlyphItem',
|
||||
'animate',
|
||||
'animateColor',
|
||||
'animateMotion',
|
||||
'animateTransform',
|
||||
'animation',
|
||||
'audio',
|
||||
'canvas',
|
||||
'clipPath',
|
||||
'color-profile',
|
||||
'cursor',
|
||||
'defs',
|
||||
'desc',
|
||||
'discard',
|
||||
'feBlend',
|
||||
'feColorMatrix',
|
||||
'feComponentTransfer',
|
||||
'feComposite',
|
||||
'feConvolveMatrix',
|
||||
'feDiffuseLighting',
|
||||
'feDisplacementMap',
|
||||
'feDistantLight',
|
||||
'feDropShadow',
|
||||
'feFlood',
|
||||
'feFuncA',
|
||||
'feFuncB',
|
||||
'feFuncG',
|
||||
'feFuncR',
|
||||
'feGaussianBlur',
|
||||
'feImage',
|
||||
'feMerge',
|
||||
'feMergeNode',
|
||||
'feMorphology',
|
||||
'feOffset',
|
||||
'fePointLight',
|
||||
'feSpecularLighting',
|
||||
'feSpotLight',
|
||||
'feTile',
|
||||
'feTurbulence',
|
||||
'filter',
|
||||
'font',
|
||||
'font-face',
|
||||
'font-face-format',
|
||||
'font-face-name',
|
||||
'font-face-src',
|
||||
'font-face-uri',
|
||||
'foreignObject',
|
||||
'g',
|
||||
'glyph',
|
||||
'glyphRef',
|
||||
'handler',
|
||||
'hatch',
|
||||
'hatchpath',
|
||||
'hkern',
|
||||
'iframe',
|
||||
'image',
|
||||
'linearGradient',
|
||||
'listener',
|
||||
'marker',
|
||||
'mask',
|
||||
'mesh',
|
||||
'meshgradient',
|
||||
'meshpatch',
|
||||
'meshrow',
|
||||
'metadata',
|
||||
'missing-glyph',
|
||||
'mpath',
|
||||
'pattern',
|
||||
'prefetch',
|
||||
'radialGradient',
|
||||
'script',
|
||||
'set',
|
||||
'solidColor',
|
||||
'solidcolor',
|
||||
'style',
|
||||
'svg',
|
||||
'switch',
|
||||
'symbol',
|
||||
'tbreak',
|
||||
'text',
|
||||
'textArea',
|
||||
'textPath',
|
||||
'title',
|
||||
'tref',
|
||||
'tspan',
|
||||
'unknown',
|
||||
'video',
|
||||
'view',
|
||||
'vkern'
|
||||
].concat(VOID_SVG_TAGS_LIST)).sort()
|
||||
|
||||
/**
|
||||
* HTML void elements that cannot be auto-closed and shouldn't contain child nodes.
|
||||
* @type {Array}
|
||||
* @see {@link http://www.w3.org/TR/html-markup/syntax.html#syntax-elements}
|
||||
* @see {@link http://www.w3.org/TR/html5/syntax.html#void-elements}
|
||||
*/
|
||||
export const VOID_HTML_TAGS_LIST = [
|
||||
'area',
|
||||
'base',
|
||||
'br',
|
||||
'col',
|
||||
'embed',
|
||||
'hr',
|
||||
'img',
|
||||
'input',
|
||||
'keygen',
|
||||
'link',
|
||||
'menuitem',
|
||||
'meta',
|
||||
'param',
|
||||
'source',
|
||||
'track',
|
||||
'wbr'
|
||||
]
|
||||
|
||||
/**
|
||||
* List of all the html tags
|
||||
* @const {Array}
|
||||
* @see {@link https://github.com/sindresorhus/html-tags}
|
||||
*/
|
||||
export const HTML_TAGS_LIST = uniq([
|
||||
'a',
|
||||
'abbr',
|
||||
'address',
|
||||
'article',
|
||||
'aside',
|
||||
'audio',
|
||||
'b',
|
||||
'bdi',
|
||||
'bdo',
|
||||
'blockquote',
|
||||
'body',
|
||||
'canvas',
|
||||
'caption',
|
||||
'cite',
|
||||
'code',
|
||||
'colgroup',
|
||||
'datalist',
|
||||
'dd',
|
||||
'del',
|
||||
'details',
|
||||
'dfn',
|
||||
'dialog',
|
||||
'div',
|
||||
'dl',
|
||||
'dt',
|
||||
'em',
|
||||
'fieldset',
|
||||
'figcaption',
|
||||
'figure',
|
||||
'footer',
|
||||
'form',
|
||||
'h1',
|
||||
'h2',
|
||||
'h3',
|
||||
'h4',
|
||||
'h5',
|
||||
'h6',
|
||||
'head',
|
||||
'header',
|
||||
'hgroup',
|
||||
'html',
|
||||
'i',
|
||||
'iframe',
|
||||
'ins',
|
||||
'kbd',
|
||||
'label',
|
||||
'legend',
|
||||
'main',
|
||||
'map',
|
||||
'mark',
|
||||
'math',
|
||||
'menu',
|
||||
'nav',
|
||||
'noscript',
|
||||
'object',
|
||||
'ol',
|
||||
'optgroup',
|
||||
'p',
|
||||
'picture',
|
||||
'pre',
|
||||
'q',
|
||||
'rb',
|
||||
'rp',
|
||||
'rt',
|
||||
'rtc',
|
||||
'ruby',
|
||||
's',
|
||||
'samp',
|
||||
'script',
|
||||
'section',
|
||||
'select',
|
||||
'slot',
|
||||
'small',
|
||||
'span',
|
||||
'strong',
|
||||
'style',
|
||||
'sub',
|
||||
'summary',
|
||||
'sup',
|
||||
'svg',
|
||||
'table',
|
||||
'tbody',
|
||||
'td',
|
||||
'template',
|
||||
'tfoot',
|
||||
'th',
|
||||
'thead',
|
||||
'time',
|
||||
'title',
|
||||
'tr',
|
||||
'u',
|
||||
'ul',
|
||||
'var',
|
||||
'video'
|
||||
]
|
||||
.concat(VOID_HTML_TAGS_LIST)
|
||||
.concat(HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_LIST)
|
||||
).sort()
|
||||
|
||||
/**
|
||||
* List of all boolean HTML attributes
|
||||
* @const {RegExp}
|
||||
* @see {@link https://www.w3.org/TR/html5/infrastructure.html#sec-boolean-attributes}
|
||||
*/
|
||||
export const BOOLEAN_ATTRIBUTES_LIST = [
|
||||
'disabled',
|
||||
'visible',
|
||||
'checked',
|
||||
'readonly',
|
||||
'required',
|
||||
'allowfullscreen',
|
||||
'autofocus',
|
||||
'autoplay',
|
||||
'compact',
|
||||
'controls',
|
||||
'default',
|
||||
'formnovalidate',
|
||||
'hidden',
|
||||
'ismap',
|
||||
'itemscope',
|
||||
'loop',
|
||||
'multiple',
|
||||
'muted',
|
||||
'noresize',
|
||||
'noshade',
|
||||
'novalidate',
|
||||
'nowrap',
|
||||
'open',
|
||||
'reversed',
|
||||
'seamless',
|
||||
'selected',
|
||||
'sortable',
|
||||
'truespeed',
|
||||
'typemustmatch'
|
||||
]
|
||||
|
||||
/**
|
||||
* Join a list of items with the pipe symbol (usefull for regex list concatenation)
|
||||
* @private
|
||||
* @param {Array} list - list of strings
|
||||
* @returns {string} the list received joined with pipes
|
||||
*/
|
||||
function joinWithPipe(list) {
|
||||
return list.join('|')
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert list of strings to regex in order to test against it ignoring the cases
|
||||
* @private
|
||||
* @param {...Array} lists - array of strings
|
||||
* @returns {RegExp} regex that will match all the strings in the array received ignoring the cases
|
||||
*/
|
||||
function listsToRegex(...lists) {
|
||||
return new RegExp(`^/?(?:${joinWithPipe(lists.map(joinWithPipe))})$`, 'i')
|
||||
}
|
||||
|
||||
/**
|
||||
* Regex matching all the html tags ignoring the cases
|
||||
* @const {RegExp}
|
||||
*/
|
||||
export const HTML_TAGS_RE = listsToRegex(HTML_TAGS_LIST)
|
||||
|
||||
/**
|
||||
* Regex matching all the svg tags ignoring the cases
|
||||
* @const {RegExp}
|
||||
*/
|
||||
export const SVG_TAGS_RE = listsToRegex(SVG_TAGS_LIST)
|
||||
|
||||
/**
|
||||
* Regex matching all the void html tags ignoring the cases
|
||||
* @const {RegExp}
|
||||
*/
|
||||
export const VOID_HTML_TAGS_RE = listsToRegex(VOID_HTML_TAGS_LIST)
|
||||
|
||||
/**
|
||||
* Regex matching all the void svg tags ignoring the cases
|
||||
* @const {RegExp}
|
||||
*/
|
||||
export const VOID_SVG_TAGS_RE = listsToRegex(VOID_SVG_TAGS_LIST)
|
||||
|
||||
/**
|
||||
* Regex matching all the html tags where the value tag is allowed
|
||||
* @const {RegExp}
|
||||
*/
|
||||
export const HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_RE = listsToRegex(HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_LIST)
|
||||
|
||||
/**
|
||||
* Regex matching all the boolean attributes
|
||||
* @const {RegExp}
|
||||
*/
|
||||
export const BOOLEAN_ATTRIBUTES_RE = listsToRegex(BOOLEAN_ATTRIBUTES_LIST)
|
||||
|
||||
/**
|
||||
* True if it's a self closing tag
|
||||
* @param {string} tag - test tag
|
||||
* @returns {boolean} true if void
|
||||
* @example
|
||||
* isVoid('meta') // true
|
||||
* isVoid('circle') // true
|
||||
* isVoid('IMG') // true
|
||||
* isVoid('div') // false
|
||||
* isVoid('mask') // false
|
||||
*/
|
||||
export function isVoid(tag) {
|
||||
return [
|
||||
VOID_HTML_TAGS_RE,
|
||||
VOID_SVG_TAGS_RE
|
||||
].some(r => r.test(tag))
|
||||
}
|
||||
|
||||
/**
|
||||
* True if it's a known HTML tag
|
||||
* @param {string} tag - test tag
|
||||
* @returns {boolean} true if html tag
|
||||
* @example
|
||||
* isHtml('img') // true
|
||||
* isHtml('IMG') // true
|
||||
* isHtml('Img') // true
|
||||
* isHtml('path') // false
|
||||
*/
|
||||
export function isHtml(tag) {
|
||||
return HTML_TAGS_RE.test(tag)
|
||||
}
|
||||
|
||||
/**
|
||||
* True if it's a known SVG tag
|
||||
* @param {string} tag - test tag
|
||||
* @returns {boolean} true if svg tag
|
||||
* @example
|
||||
* isSvg('g') // true
|
||||
* isSvg('radialGradient') // true
|
||||
* isSvg('radialgradient') // true
|
||||
* isSvg('div') // false
|
||||
*/
|
||||
export function isSvg(tag) {
|
||||
return SVG_TAGS_RE.test(tag)
|
||||
}
|
||||
|
||||
/**
|
||||
* True if it's not SVG nor a HTML known tag
|
||||
* @param {string} tag - test tag
|
||||
* @returns {boolean} true if custom element
|
||||
* @example
|
||||
* isCustom('my-component') // true
|
||||
* isCustom('div') // false
|
||||
*/
|
||||
export function isCustom(tag) {
|
||||
return [
|
||||
HTML_TAGS_RE,
|
||||
SVG_TAGS_RE
|
||||
].every(l => !l.test(tag))
|
||||
}
|
||||
|
||||
/**
|
||||
* True if the value attribute is allowed on this tag
|
||||
* @param {string} tag - test tag
|
||||
* @returns {boolean} true if the value attribute is allowed
|
||||
* @example
|
||||
* hasValueAttribute('input') // true
|
||||
* hasValueAttribute('div') // false
|
||||
*/
|
||||
export function hasValueAttribute(tag) {
|
||||
return HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_RE.test(tag)
|
||||
}
|
||||
|
||||
/**
|
||||
* True if it's a boolean attribute
|
||||
* @param {string} attribute - test attribute
|
||||
* @returns {boolean} true if the attribute is a boolean type
|
||||
* @example
|
||||
* isBoolAttribute('selected') // true
|
||||
* isBoolAttribute('class') // false
|
||||
*/
|
||||
export function isBoolAttribute(attribute) {
|
||||
return BOOLEAN_ATTRIBUTES_RE.test(attribute)
|
||||
}
|
41
node_modules/dom-nodes/package.json
generated
vendored
Normal file
41
node_modules/dom-nodes/package.json
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "dom-nodes",
|
||||
"version": "1.1.3",
|
||||
"description": "List of all the available DOM and SVG nodes and helper functions to quickly test against them",
|
||||
"main": "dom-nodes.js",
|
||||
"jsnext:main": "index.next.js",
|
||||
"module": "index.next.js",
|
||||
"scripts": {
|
||||
"prepare": "npm run build && npm test",
|
||||
"lint": "eslint index.next.js test.js rollup.config.js",
|
||||
"build": "rollup -c",
|
||||
"doc": "npx documentation readme index.next.js -s API",
|
||||
"test": "npm run build && npm run lint && mocha test.js"
|
||||
},
|
||||
"files": [
|
||||
"index.next.js"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/riot/dom-nodes.git"
|
||||
},
|
||||
"keywords": [
|
||||
"html",
|
||||
"svg",
|
||||
"void",
|
||||
"dom",
|
||||
"riot"
|
||||
],
|
||||
"author": "Gianluca Guarini <gianluca.guarini@gmail.com> (http://gianlucaguarini.com)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/riot/dom-nodes/issues"
|
||||
},
|
||||
"homepage": "https://github.com/riot/dom-nodes#readme",
|
||||
"devDependencies": {
|
||||
"eslint-config-riot": "^3.0.0",
|
||||
"eslint": "^6.1.0",
|
||||
"mocha": "^6.2.0",
|
||||
"rollup": "^1.18.0"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user