@markuplint/ml-spec 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isExposed = void 0;
|
|
4
4
|
const aria_specs_1 = require("../specs/aria-specs");
|
|
5
5
|
const get_spec_by_tag_name_1 = require("../specs/get-spec-by-tag-name");
|
|
6
|
-
const is_palpable_elements_1 = require("../specs/is-palpable-elements");
|
|
7
6
|
const is_presentational_1 = require("../specs/is-presentational");
|
|
8
7
|
const resolve_namespace_1 = require("../utils/resolve-namespace");
|
|
9
8
|
const get_computed_role_1 = require("./get-computed-role");
|
|
@@ -29,7 +28,7 @@ function isExposed(el, specs, version) {
|
|
|
29
28
|
}
|
|
30
29
|
// According to HTML and SVG Specs with **the author's interpretation**
|
|
31
30
|
{
|
|
32
|
-
if (!(
|
|
31
|
+
if (!isExposedElement(el, specs)) {
|
|
33
32
|
return false;
|
|
34
33
|
}
|
|
35
34
|
}
|
|
@@ -187,3 +186,19 @@ function hasDisplayNodeOrVisibilityHidden(el) {
|
|
|
187
186
|
// TODO: Improve accuracy
|
|
188
187
|
return /display\s*:\s*none|visibility\s*:\s*hidden/gi.test(style);
|
|
189
188
|
}
|
|
189
|
+
function isExposedElement(el, specs) {
|
|
190
|
+
var _a;
|
|
191
|
+
const svgRenderedConditions = (_a = specs.def['#contentModels']['#SVGRenderable']) === null || _a === void 0 ? void 0 : _a.join(',');
|
|
192
|
+
if (svgRenderedConditions && el.matches(svgRenderedConditions)) {
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
return isNotMetaOrHiddenHTMLElement(el, specs);
|
|
196
|
+
}
|
|
197
|
+
function isNotMetaOrHiddenHTMLElement(el, specs) {
|
|
198
|
+
var _a;
|
|
199
|
+
const metadataConditions = (_a = specs.def['#contentModels']['#metadata']) === null || _a === void 0 ? void 0 : _a.join(',');
|
|
200
|
+
if (metadataConditions && el.matches(metadataConditions)) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
return !el.matches('input[type=hidden i]');
|
|
204
|
+
}
|
|
@@ -12,8 +12,7 @@ export interface AttributesSchema {
|
|
|
12
12
|
}
|
|
13
13
|
export interface GlobalAttributes {
|
|
14
14
|
'#HTMLGlobalAttrs'?: boolean;
|
|
15
|
-
'#GlobalEventAttrs'?: boolean | ('onabort' | 'onauxclick' | 'onbeforeinput' | 'onbeforematch' | 'onblur' | 'oncancel' | 'oncanplay' | 'oncanplaythrough' | 'onchange' | 'onclick' | 'onclose' | '
|
|
16
|
-
'#DocumentElementEventAttrs'?: boolean | ('oncopy' | 'oncut' | 'onpaste')[];
|
|
15
|
+
'#GlobalEventAttrs'?: boolean | ('onabort' | 'onauxclick' | 'onbeforeinput' | 'onbeforematch' | 'onblur' | 'oncancel' | 'oncanplay' | 'oncanplaythrough' | 'onchange' | 'onclick' | 'onclose' | 'oncompositionend' | 'oncompositionstart' | 'oncompositionupdate' | 'oncontextlost' | 'oncontextmenu' | 'oncontextrestored' | 'oncopy' | 'oncuechange' | 'oncut' | 'ondblclick' | 'ondrag' | 'ondragend' | 'ondragenter' | 'ondragleave' | 'ondragover' | 'ondragstart' | 'ondrop' | 'ondurationchange' | 'onemptied' | 'onended' | 'onerror' | 'onfocus' | 'onfocusin' | 'onfocusout' | 'onformdata' | 'oninput' | 'oninvalid' | 'onkeydown' | 'onkeypress' | 'onkeyup' | 'onload' | 'onloadeddata' | 'onloadedmetadata' | 'onloadstart' | 'onmousedown' | 'onmouseenter' | 'onmouseleave' | 'onmousemove' | 'onmouseout' | 'onmouseover' | 'onmouseup' | 'onpaste' | 'onpause' | 'onplay' | 'onplaying' | 'onprogress' | 'onratechange' | 'onreset' | 'onresize' | 'onscroll' | 'onsecuritypolicyviolation' | 'onseeked' | 'onseeking' | 'onselect' | 'onslotchange' | 'onstalled' | 'onsubmit' | 'onsuspend' | 'ontimeupdate' | 'ontoggle' | 'onunload' | 'onvolumechange' | 'onwaiting' | 'onwebkitanimationend' | 'onwebkitanimationiteration' | 'onwebkitanimationstart' | 'onwebkittransitionend' | 'onwheel')[];
|
|
17
16
|
/**
|
|
18
17
|
* @minItems 0
|
|
19
18
|
*/
|
|
@@ -19,13 +19,13 @@ export interface ContentModel {
|
|
|
19
19
|
}[];
|
|
20
20
|
}
|
|
21
21
|
export interface PermittedContentRequire {
|
|
22
|
-
require: Model;
|
|
22
|
+
require: Model | PermittedContentPattern[];
|
|
23
23
|
max?: number;
|
|
24
24
|
min?: number;
|
|
25
25
|
_TODO_?: string;
|
|
26
26
|
}
|
|
27
27
|
export interface PermittedContentOptional {
|
|
28
|
-
optional: Model;
|
|
28
|
+
optional: Model | PermittedContentPattern[];
|
|
29
29
|
max?: number;
|
|
30
30
|
_TODO_?: string;
|
|
31
31
|
}
|
|
@@ -40,6 +40,10 @@ export interface PermittedContentZeroOrMore {
|
|
|
40
40
|
_TODO_?: string;
|
|
41
41
|
}
|
|
42
42
|
export interface PermittedContentChoice {
|
|
43
|
+
/**
|
|
44
|
+
* @minItems 2
|
|
45
|
+
* @maxItems 5
|
|
46
|
+
*/
|
|
43
47
|
choice: [PermittedContentPattern[], PermittedContentPattern[]] | [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]] | [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]] | [
|
|
44
48
|
PermittedContentPattern[],
|
|
45
49
|
PermittedContentPattern[],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/ml-spec",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Types and schema that specs of the Markup languages for markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dev": "tsc --build --watch",
|
|
17
17
|
"clean": "tsc --build --clean",
|
|
18
18
|
"schema:gen": "ts-node ./gen/gen.ts; prettier --write './schemas/*.json';",
|
|
19
|
-
"schema:content-models": "json2ts ./schemas/content-models.schema.json > ./src/types/permitted-
|
|
19
|
+
"schema:content-models": "json2ts ./schemas/content-models.schema.json > ./src/types/permitted-structures.ts; prettier --write ./src/types/permitted-structures.ts; eslint --fix --config ../../../.eslintrc ./src/types/permitted-structures.ts",
|
|
20
20
|
"schema:attributes": "json2ts ./schemas/attributes.schema.json --cwd ./schemas > ./src/types/attributes.ts; prettier --write ./src/types/attributes.ts; eslint --fix --config ../../../.eslintrc ./src/types/attributes.ts",
|
|
21
21
|
"schema:aria": "json2ts ./schemas/aria.schema.json --cwd ./schemas > ./src/types/aria.ts; prettier --write ./src/types/aria.ts; eslint --fix --config ../../../.eslintrc ./src/types/aria.ts",
|
|
22
22
|
"schema": "run-s schema:*"
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"@markuplint/types": "3.0.0",
|
|
32
32
|
"json-schema-to-typescript": "^11.0.2"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "0e75df6944f453bc19d2a6e05ad264788a8dc149"
|
|
35
35
|
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was automatically generated by json-schema-to-typescript.
|
|
3
|
-
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
4
|
-
* and run json-schema-to-typescript to regenerate this file.
|
|
5
|
-
*/
|
|
6
|
-
export type PermittedContentPattern = PermittedContentRequire | PermittedContentOptional | PermittedContentOneOrMore | PermittedContentZeroOrMore | PermittedContentChoice | PermittedContentTransparent;
|
|
7
|
-
export type Model = ContentType | ContentType[];
|
|
8
|
-
export type ContentType = string | Category;
|
|
9
|
-
export type Category = '#text' | '#phrasing' | '#flow' | '#interactive' | '#heading' | '#sectioning' | '#metadata' | '#embedded' | '#palpable' | '#script-supporting' | '#SVGAnimation' | '#SVGBasicShapes' | '#SVGContainer' | '#SVGDescriptive' | '#SVGFilterPrimitive' | '#SVGFont' | '#SVGGradient' | '#SVGGraphics' | '#SVGGraphicsReferencing' | '#SVGLightSource' | '#SVGNeverRendered' | '#SVGNone' | '#SVGPaintServer' | '#SVGRenderable' | '#SVGShape' | '#SVGStructural' | '#SVGStructurallyExternal' | '#SVGTextContent' | '#SVGTextContentChild';
|
|
10
|
-
export interface ContentModelsSchema {
|
|
11
|
-
__contentModel?: ContentModel;
|
|
12
|
-
}
|
|
13
|
-
export interface ContentModel {
|
|
14
|
-
contents: PermittedContentPattern[] | boolean;
|
|
15
|
-
descendantOf?: string;
|
|
16
|
-
conditional?: {
|
|
17
|
-
condition: string;
|
|
18
|
-
contents: PermittedContentPattern[] | boolean;
|
|
19
|
-
}[];
|
|
20
|
-
}
|
|
21
|
-
export interface PermittedContentRequire {
|
|
22
|
-
require: Model;
|
|
23
|
-
max?: number;
|
|
24
|
-
min?: number;
|
|
25
|
-
_TODO_?: string;
|
|
26
|
-
}
|
|
27
|
-
export interface PermittedContentOptional {
|
|
28
|
-
optional: Model;
|
|
29
|
-
max?: number;
|
|
30
|
-
_TODO_?: string;
|
|
31
|
-
}
|
|
32
|
-
export interface PermittedContentOneOrMore {
|
|
33
|
-
oneOrMore: Model | PermittedContentPattern[];
|
|
34
|
-
max?: number;
|
|
35
|
-
_TODO_?: string;
|
|
36
|
-
}
|
|
37
|
-
export interface PermittedContentZeroOrMore {
|
|
38
|
-
zeroOrMore: Model | PermittedContentPattern[];
|
|
39
|
-
max?: number;
|
|
40
|
-
_TODO_?: string;
|
|
41
|
-
}
|
|
42
|
-
export interface PermittedContentChoice {
|
|
43
|
-
/**
|
|
44
|
-
* @minItems 2
|
|
45
|
-
* @maxItems 5
|
|
46
|
-
*/
|
|
47
|
-
choice: [PermittedContentPattern[], PermittedContentPattern[]] | [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]] | [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]] | [
|
|
48
|
-
PermittedContentPattern[],
|
|
49
|
-
PermittedContentPattern[],
|
|
50
|
-
PermittedContentPattern[],
|
|
51
|
-
PermittedContentPattern[],
|
|
52
|
-
PermittedContentPattern[]
|
|
53
|
-
];
|
|
54
|
-
_TODO_?: string;
|
|
55
|
-
}
|
|
56
|
-
export interface PermittedContentTransparent {
|
|
57
|
-
transparent: string;
|
|
58
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
/**
|
|
4
|
-
* This file was automatically generated by json-schema-to-typescript.
|
|
5
|
-
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
6
|
-
* and run json-schema-to-typescript to regenerate this file.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|