@riotjs/parser
Advanced tools
Comparing version 4.0.3 to 4.1.0
# Changes for riot-parser | ||
### v4.1.0 | ||
- Add expose the internal constants to the public API | ||
### v4.0.3 | ||
@@ -4,0 +7,0 @@ - Fix https://github.com/riot/riot/issues/2723 for real this time |
120
index.js
@@ -5,2 +5,34 @@ 'use strict'; | ||
const JAVASCRIPT_OUTPUT_NAME = 'javascript'; | ||
const CSS_OUTPUT_NAME = 'css'; | ||
const TEMPLATE_OUTPUT_NAME = 'template'; | ||
// Tag names | ||
const JAVASCRIPT_TAG = 'script'; | ||
const STYLE_TAG = 'style'; | ||
const TEXTAREA_TAG = 'textarea'; | ||
// Boolean attributes | ||
const IS_RAW = 'isRaw'; | ||
const IS_SELF_CLOSING = 'isSelfClosing'; | ||
const IS_VOID = 'isVoid'; | ||
const IS_BOOLEAN = 'isBoolean'; | ||
const IS_CUSTOM = 'isCustom'; | ||
const IS_SPREAD = 'isSpread'; | ||
var c = /*#__PURE__*/Object.freeze({ | ||
JAVASCRIPT_OUTPUT_NAME: JAVASCRIPT_OUTPUT_NAME, | ||
CSS_OUTPUT_NAME: CSS_OUTPUT_NAME, | ||
TEMPLATE_OUTPUT_NAME: TEMPLATE_OUTPUT_NAME, | ||
JAVASCRIPT_TAG: JAVASCRIPT_TAG, | ||
STYLE_TAG: STYLE_TAG, | ||
TEXTAREA_TAG: TEXTAREA_TAG, | ||
IS_RAW: IS_RAW, | ||
IS_SELF_CLOSING: IS_SELF_CLOSING, | ||
IS_VOID: IS_VOID, | ||
IS_BOOLEAN: IS_BOOLEAN, | ||
IS_CUSTOM: IS_CUSTOM, | ||
IS_SPREAD: IS_SPREAD | ||
}); | ||
/** | ||
@@ -83,19 +115,2 @@ * Not all the types are handled in this module. | ||
const JAVASCRIPT_OUTPUT_NAME = 'javascript'; | ||
const CSS_OUTPUT_NAME = 'css'; | ||
const TEMPLATE_OUTPUT_NAME = 'template'; | ||
// Tag names | ||
const JAVASCRIPT_TAG = 'script'; | ||
const STYLE_TAG = 'style'; | ||
const TEXTAREA_TAG = 'textarea'; | ||
// Boolean attributes | ||
const IS_RAW = 'isRaw'; | ||
const IS_SELF_CLOSING = 'isSelfClosing'; | ||
const IS_VOID = 'isVoid'; | ||
const IS_BOOLEAN = 'isBoolean'; | ||
const IS_CUSTOM = 'isCustom'; | ||
const IS_SPREAD = 'isSpread'; | ||
/** | ||
@@ -606,2 +621,5 @@ * Add an item into a collection, if the collection is not an array | ||
// similar to _.uniq | ||
const uniq = l => l.filter((x, i, a) => a.indexOf(x) === i); | ||
/** | ||
@@ -624,2 +642,20 @@ * SVG void elements that cannot be auto-closed and shouldn't contain child nodes. | ||
/** | ||
* 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 | ||
@@ -629,3 +665,3 @@ * @const {Array} | ||
*/ | ||
const SVG_TAGS_LIST = [ | ||
const SVG_TAGS_LIST = uniq([ | ||
'a', | ||
@@ -723,3 +759,3 @@ 'altGlyph', | ||
'vkern' | ||
].concat(VOID_SVG_TAGS_LIST).sort(); | ||
].concat(VOID_SVG_TAGS_LIST)).sort(); | ||
@@ -756,3 +792,3 @@ /** | ||
*/ | ||
const HTML_TAGS_LIST = [ | ||
const HTML_TAGS_LIST = uniq([ | ||
'a', | ||
@@ -769,3 +805,2 @@ 'abbr', | ||
'body', | ||
'button', | ||
'canvas', | ||
@@ -776,3 +811,2 @@ 'caption', | ||
'colgroup', | ||
'data', | ||
'datalist', | ||
@@ -809,3 +843,2 @@ 'dd', | ||
'legend', | ||
'li', | ||
'main', | ||
@@ -816,3 +849,2 @@ 'map', | ||
'menu', | ||
'meter', | ||
'nav', | ||
@@ -823,8 +855,5 @@ 'noscript', | ||
'optgroup', | ||
'option', | ||
'output', | ||
'p', | ||
'picture', | ||
'pre', | ||
'progress', | ||
'q', | ||
@@ -854,3 +883,2 @@ 'rb', | ||
'template', | ||
'textarea', | ||
'tfoot', | ||
@@ -866,9 +894,11 @@ 'th', | ||
'video' | ||
].concat(VOID_HTML_TAGS_LIST).sort(); | ||
] | ||
.concat(VOID_HTML_TAGS_LIST) | ||
.concat(HTML_ELEMENTS_HAVING_VALUE_ATTRIBUTE_LIST) | ||
).sort(); | ||
/** | ||
* Matches boolean HTML attributes in the riot tag definition. | ||
* With a long list like this, a regex is faster than `[].indexOf` in most browsers. | ||
* List of all boolean HTML attributes | ||
* @const {RegExp} | ||
* @see [attributes.md](https://github.com/riot/compiler/blob/dev/doc/attributes.md) | ||
* @see {@link https://www.w3.org/TR/html5/infrastructure.html#sec-boolean-attributes} | ||
*/ | ||
@@ -911,3 +941,3 @@ const BOOLEAN_ATTRIBUTES_LIST = [ | ||
* @param {Array} list - list of strings | ||
* @returns {String} the list received joined with pipes | ||
* @returns {string} the list received joined with pipes | ||
*/ | ||
@@ -953,2 +983,8 @@ function joinWithPipe(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 | ||
@@ -961,4 +997,4 @@ * @const {RegExp} | ||
* True if it's a self closing tag | ||
* @param {String} tag - test tag | ||
* @returns {Boolean} | ||
* @param {string} tag - test tag | ||
* @returns {boolean} true if void | ||
* @example | ||
@@ -980,4 +1016,4 @@ * isVoid('meta') // true | ||
* True if it's not SVG nor a HTML known tag | ||
* @param {String} tag - test tag | ||
* @returns {Boolean} | ||
* @param {string} tag - test tag | ||
* @returns {boolean} true if custom element | ||
* @example | ||
@@ -996,4 +1032,4 @@ * isCustom('my-component') // true | ||
* True if it's a boolean attribute | ||
* @param {String} attribute - test attribute | ||
* @returns {Boolean} | ||
* @param {string} attribute - test attribute | ||
* @returns {boolean} true if the attribute is a boolean type | ||
* @example | ||
@@ -1729,2 +1765,7 @@ * isBoolAttribute('selected') // true | ||
/** | ||
* Expose the internal constants | ||
*/ | ||
const constants = c; | ||
/** | ||
* The nodeTypes definition | ||
@@ -1734,3 +1775,4 @@ */ | ||
exports.constants = constants; | ||
exports.default = parser; | ||
exports.nodeTypes = nodeTypes; |
{ | ||
"name": "@riotjs/parser", | ||
"version": "4.0.3", | ||
"version": "4.1.0", | ||
"description": "The parser for Riot tags", | ||
@@ -50,8 +50,8 @@ "main": "./index.js", | ||
"chai": "^4.2.0", | ||
"coveralls": "^3.0.4", | ||
"eslint": "^6.0.1", | ||
"eslint-config-riot": "^2.0.0", | ||
"mocha": "^6.1.4", | ||
"coveralls": "^3.0.6", | ||
"eslint": "^6.4.0", | ||
"eslint-config-riot": "^3.0.0", | ||
"mocha": "^6.2.0", | ||
"nyc": "^14.1.1", | ||
"rollup": "^1.16.3", | ||
"rollup": "^1.21.4", | ||
"rollup-plugin-node-resolve": "^5.2.0" | ||
@@ -61,4 +61,4 @@ }, | ||
"curri": "^1.0.1", | ||
"dom-nodes": "^1.0.0" | ||
"dom-nodes": "^1.1.3" | ||
} | ||
} |
@@ -0,1 +1,2 @@ | ||
import * as c from './constants' | ||
import * as types from './node-types' | ||
@@ -5,2 +6,7 @@ import parser from './parser' | ||
/** | ||
* Expose the internal constants | ||
*/ | ||
export const constants = c | ||
/** | ||
* The nodeTypes definition | ||
@@ -14,1 +20,2 @@ */ | ||
export default parser | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99531
2795
Updateddom-nodes@^1.1.3