...
 
Commits (6)
# html-validate changelog
# [1.11.0](https://gitlab.com/html-validate/html-validate/compare/v1.10.0...v1.11.0) (2019-09-23)
### Bug Fixes
- **config:** expand `<rootDir>` in elements ([eeddf4c](https://gitlab.com/html-validate/html-validate/commit/eeddf4c))
### Features
- **meta:** new property `scriptSupporting` ([c271a04](https://gitlab.com/html-validate/html-validate/commit/c271a04))
# [1.10.0](https://gitlab.com/html-validate/html-validate/compare/v1.9.1...v1.10.0) (2019-09-19)
### Features
......
......@@ -36,6 +36,7 @@ export interface MetaElement {
foreign: boolean;
void: boolean;
transparent: boolean;
scriptSupporting: boolean;
/* attributes */
deprecatedAttributes: string[];
......@@ -130,6 +131,15 @@ as a child of a `<span>` element (phrasing) it only allows new phrasing content.
For custom elements it can be useful to set this if the content category isn't
flow.
### `scriptSupporting`
Elements whose primary purpose is to support scripting should set this flag to `true`.
Some elements will generally only allow a very narrow set of children (such as `<ul>` only allowing `<li>`) but usually also allows [script-supporting elements][whatwg-scriptsupporting].
In HTML5 both the `<script>` and `<template>` tags are considered script-supporting but javascript frameworks and web-components may include additional tags.
[whatwg-scriptsupporting]: https://html.spec.whatwg.org/multipage/dom.html#script-supporting-elements-2
## Permitted content
### `attributes`
......
......@@ -263,7 +263,7 @@
"dl": {
"flow": true,
"deprecatedAttributes": ["compact"],
"permittedContent": ["dt", "dd", "div", "script", "template"]
"permittedContent": ["@script", "dt", "dd", "div"]
},
"dt": {
......@@ -712,7 +712,7 @@
"type": ["a", "A", "i", "I", "1"]
},
"deprecatedAttributes": ["compact"],
"permittedContent": ["li", "script", "template"]
"permittedContent": ["@script", "li"]
},
"optgroup": {
......@@ -720,7 +720,7 @@
"attributes": {
"disabled": []
},
"permittedContent": ["option", "script", "template"]
"permittedContent": ["@script", "option"]
},
"option": {
......@@ -782,7 +782,7 @@
"flow": true,
"phrasing": true,
"embedded": true,
"permittedContent": ["source", "img", "script", "template"],
"permittedContent": ["@script", "source", "img"],
"permittedOrder": ["source", "img"]
},
......@@ -851,6 +851,7 @@
"metadata": true,
"flow": true,
"phrasing": true,
"scriptSupporting": true,
"attributes": {
"async": [],
"crossorigin": ["", "anonymous", "use-credentials"],
......@@ -880,13 +881,12 @@
"size": ["/\\d+/"]
},
"permittedContent": [
"@script",
"datasrc",
"datafld",
"dataformatas",
"option",
"optgroup",
"script",
"template"
"optgroup"
]
},
......@@ -969,11 +969,10 @@
"width"
],
"permittedContent": [
"@script",
"caption?",
"colgroup",
"script",
"tbody",
"template",
"tfoot?",
"thead?",
"tr"
......@@ -990,7 +989,7 @@
"charoff",
"valign"
],
"permittedContent": ["tr", "script", "template"]
"permittedContent": ["@script", "tr"]
},
"td": {
......@@ -1019,7 +1018,8 @@
"template": {
"metadata": true,
"flow": true,
"phrasing": true
"phrasing": true,
"scriptSupporting": true
},
"textarea": {
......@@ -1052,7 +1052,7 @@
"charoff",
"valign"
],
"permittedContent": ["tr", "script", "template"]
"permittedContent": ["@script", "tr"]
},
"th": {
......@@ -1091,7 +1091,7 @@
"charoff",
"valign"
],
"permittedContent": ["tr", "script", "template"]
"permittedContent": ["@script", "tr"]
},
"time": {
......@@ -1115,7 +1115,7 @@
"charoff",
"valign"
],
"permittedContent": ["td", "th", "script", "template"]
"permittedContent": ["@script", "td", "th"]
},
"track": {
......@@ -1135,7 +1135,7 @@
"ul": {
"flow": true,
"deprecatedAttributes": ["compact", "type"],
"permittedContent": ["li", "script", "template"]
"permittedContent": ["@script", "li"]
},
"var": {
......
......@@ -20,6 +20,7 @@
"void": { "type": "boolean" },
"transparent": { "type": "boolean" },
"implicitClosed": { "type": "array", "contains": { "type": "string" } },
"scriptSupporting": { "type": "boolean" },
"deprecatedAttributes": {
"type": "array",
......
{
"name": "html-validate",
"version": "1.10.0",
"version": "1.11.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -1892,9 +1892,9 @@
"dev": true
},
"@semantic-release/exec": {
"version": "3.3.6",
"resolved": "https://registry.npmjs.org/@semantic-release/exec/-/exec-3.3.6.tgz",
"integrity": "sha512-Nme7mgDHaoj+mc+hC7HCQB5r6c6f6P0jg/ZntG3AyyO8wPVQOXunbF8Qmhk5+JVlCer0ubPW7BlBXSi6pCbdzw==",
"version": "3.3.7",
"resolved": "https://registry.npmjs.org/@semantic-release/exec/-/exec-3.3.7.tgz",
"integrity": "sha512-X7PKvhUi9PwnwKpCJSIe+liSEXLudc1cVXEvXHFTOVEbFyokd6G8y1+6hr3NqgMfEBfiH5uilySvszQIud5nZw==",
"dev": true,
"requires": {
"@semantic-release/error": "^2.1.0",
......@@ -12130,9 +12130,9 @@
"dev": true
},
"lint-staged": {
"version": "9.2.5",
"resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-9.2.5.tgz",
"integrity": "sha512-d99gTBFMJ29159+9iRvaMEQstmNcPAbQbhHSYw6D/1FncvFdIj8lWHztaq3Uq+tbZPABHXQ/fyN7Rp1QwF8HIw==",
"version": "9.3.0",
"resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-9.3.0.tgz",
"integrity": "sha512-OuL3xo6XpBErl16+3W9PdnFmgeGp12lM8I1Ii/B56S8Edy1kyrf4W8VD4IBn9v17QlutRQEWUJ54YF/VVQ7J2A==",
"dev": true,
"requires": {
"chalk": "^2.4.2",
......@@ -20599,9 +20599,9 @@
}
},
"string-argv": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.0.tgz",
"integrity": "sha512-NGZHq3nkSXVtGZXTBjFru3MNfoZyIzN25T7BmvdgnSC0LCJczAGLLMQLyjywSIaAoqSemgLzBRHOsnrHbt60+Q==",
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz",
"integrity": "sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==",
"dev": true
},
"string-length": {
......
{
"name": "html-validate",
"version": "1.10.0",
"version": "1.11.0",
"description": "html linter",
"keywords": [
"html",
......@@ -108,7 +108,7 @@
"@babel/core": "7.6.0",
"@babel/preset-env": "7.6.0",
"@semantic-release/changelog": "3.0.4",
"@semantic-release/exec": "3.3.6",
"@semantic-release/exec": "3.3.7",
"@semantic-release/git": "7.0.16",
"@semantic-release/gitlab": "3.1.7",
"@semantic-release/npm": "5.1.15",
......@@ -152,7 +152,7 @@
"jest-diff": "24.9.0",
"jest-junit": "8.0.0",
"jquery": "3.4.1",
"lint-staged": "9.2.5",
"lint-staged": "9.3.0",
"load-grunt-tasks": "5.1.0",
"minimatch": "3.0.4",
"prettier": "1.18.2",
......
......@@ -200,16 +200,19 @@ export class Config {
continue;
}
let filename: string;
/* try searching builtin metadata */
const filename = `${root}/elements/${entry}.json`;
filename = `${root}/elements/${entry}.json`;
if (fs.existsSync(filename)) {
metaTable.loadFromFile(filename);
continue;
}
/* try as regular file */
if (fs.existsSync(entry)) {
metaTable.loadFromFile(entry);
filename = entry.replace("<rootDir>", this.rootDir);
if (fs.existsSync(filename)) {
metaTable.loadFromFile(filename);
continue;
}
......
......@@ -641,6 +641,7 @@ function mockEntry(stub = {}): MetaData {
deprecated: false,
void: false,
transparent: false,
scriptSupporting: false,
},
stub
);
......
......@@ -30,6 +30,7 @@ export interface MetaData {
void: boolean;
transparent: boolean;
implicitClosed?: string[];
scriptSupporting: boolean;
/* attribute */
deprecatedAttributes?: string[];
......
......@@ -321,6 +321,7 @@ function mockEntry(stub = {}): MetaData {
deprecated: false,
void: false,
transparent: false,
scriptSupporting: false,
},
stub
);
......
......@@ -589,6 +589,7 @@ function mockEntry(stub = {}): MetaData {
deprecated: false,
void: false,
transparent: false,
scriptSupporting: false,
},
stub
);
......
......@@ -235,6 +235,7 @@ export class Validator {
* @param {HtmlElement} node - The node to test against
* @param {string} category - Name of category with '@' prefix or tag name.
*/
// eslint-disable-next-line complexity
private static validatePermittedCategory(
node: HtmlElement,
category: string
......@@ -265,6 +266,8 @@ export class Validator {
return node.meta.embedded as boolean;
case "@interactive":
return node.meta.interactive as boolean;
case "@script":
return node.meta.scriptSupporting;
default:
throw new Error(`Invalid content category "${category}"`);
}
......