@markuplint/ml-spec 1.5.0 → 2.0.0-dev.26

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.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @markuplint/ml-spec
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/%40markuplint%2Fml-spec.svg)](https://www.npmjs.com/package/@markuplint/ml-spec)
4
- [![Build Status](https://travis-ci.org/markuplint/markuplint.svg?branch=master)](https://travis-ci.org/markuplint/markuplint)
5
- [![Coverage Status](https://coveralls.io/repos/github/markuplint/markuplint/badge.svg?branch=master)](https://coveralls.io/github/markuplint/markuplint?branch=master)
4
+ [![Build Status](https://travis-ci.org/markuplint/markuplint.svg?branch=main)](https://travis-ci.org/markuplint/markuplint)
5
+ [![Coverage Status](https://coveralls.io/repos/github/markuplint/markuplint/badge.svg?branch=main)](https://coveralls.io/github/markuplint/markuplint?branch=main)
6
6
 
7
7
  ## Install
8
8
 
@@ -17,7 +17,7 @@ $ yarn add @markuplint/ml-spec
17
17
  ## Contributing
18
18
 
19
19
  ```
20
- $ git clone git@github.com:markuplint/markuplint.git -b master
20
+ $ git clone git@github.com:markuplint/markuplint.git -b main
21
21
  $ yarn
22
22
  $ yarn build
23
23
  $ yarn test
@@ -0,0 +1,31 @@
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 declare type AttributeType = ('String' | 'NonEmptyString' | 'Boolean' | 'Function' | 'Date' | 'Int' | 'Uint' | 'Float' | 'NonZeroUint' | 'ZeroToOne' | 'AcceptList' | 'AutoComplete' | 'BCP47' | 'Color' | 'ColSpan' | 'Coords' | 'Crossorigin' | 'DateTime' | 'Destination' | 'DOMID' | 'DOMIDList' | 'IRI' | 'ItemType' | 'LinkSizes' | 'LinkType' | 'LinkTypeList' | 'MediaQuery' | 'MediaQueryList' | 'MIMEType' | 'ReferrerPolicy' | 'RowSpan' | 'SourceSizeList' | 'SrcSet' | 'TabIndex' | 'Target' | 'URL' | 'URLHash' | 'URLList' | 'CSSAngle' | 'CSSBlendMode' | 'CSSClipPath' | 'CSSCustomIdent' | 'CSSDisplay' | 'CSSFilter' | 'CSSFontFamily' | 'CSSFontSize' | 'CSSFontVariant' | 'CSSFontWeight' | 'CSSMask' | 'CSSOpacity' | 'CSSTextDecoration' | 'CSSTransformList' | 'CSSTransformOrigin' | 'CSSURL' | 'SVGAnimatableValue' | 'SVGBeginValueList' | 'SVGClockValue' | 'SVGColorMatrix' | 'SVGDashArray' | 'SVGEndValueList' | 'SVGFilterPrimitiveReference' | 'SVGKernelMatrix' | 'SVGKeyPoints' | 'SVGKeySplines' | 'SVGKeyTimes' | 'SVGLanguageTags' | 'SVGLength' | 'SVGLengthList' | 'SVGNumberList' | 'SVGNumberOptionalNumber' | 'SVGOrigin' | 'SVGPaint' | 'SVGPathCommands' | 'SVGPercentage' | 'SVGPercentageList' | 'SVGPoints' | 'SVGPreserveAspectRatio' | 'SVGViewBox') | {
7
+ enum: string[];
8
+ };
9
+ export declare type AttributeCondition = {
10
+ ancestor: string;
11
+ } | {
12
+ self: string | string[];
13
+ };
14
+ export interface AttributesSchema {
15
+ tag: string;
16
+ attributes: (('#globalAttrs' | '#ariaAttrs' | '#SVGAnimationAdditionAttrs' | '#SVGAnimationAttributeTargetAttrs' | '#SVGAnimationEventAttrs' | '#SVGAnimationTargetElementAttrs' | '#SVGAnimationTimingAttrs' | '#SVGAnimationValueAttrs' | '#SVGConditionalProcessingAttrs' | '#SVGCoreAttrs' | '#SVGDocumentElementEventAttrs' | '#SVGDocumentEventAttrs' | '#SVGFilterPrimitiveAttrs' | '#SVGGlobalEventAttrs' | '#SVGGraphicalEventAttrs' | '#SVGPresentationAttrs' | '#SVGTransferFunctionAttrs' | '#XLinkAttrs') | AttributeJSON | DefineDefaultAttributeType)[];
17
+ }
18
+ export interface AttributeJSON {
19
+ name: string;
20
+ type: AttributeType | [AttributeType, ...AttributeType[]];
21
+ defaultValue?: string;
22
+ deprecated?: boolean;
23
+ required?: boolean | AttributeCondition;
24
+ requiredEither?: string[];
25
+ noUse?: boolean;
26
+ condition?: AttributeCondition;
27
+ }
28
+ export interface DefineDefaultAttributeType {
29
+ name: string;
30
+ defaultValue: string;
31
+ }
@@ -0,0 +1,8 @@
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 });
@@ -0,0 +1 @@
1
+ export declare function getNS(namespaceURI: string): "svg" | "mml" | "html";
package/lib/get-ns.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNS = void 0;
4
+ function getNS(namespaceURI) {
5
+ switch (namespaceURI) {
6
+ case 'http://www.w3.org/2000/svg': {
7
+ return 'svg';
8
+ }
9
+ case 'http://www.w3.org/1998/Math/MathML': {
10
+ return 'mml';
11
+ }
12
+ default: {
13
+ return 'html';
14
+ }
15
+ }
16
+ }
17
+ exports.getNS = getNS;
@@ -1,2 +1,2 @@
1
- import { MLDOMElementSpec, MLMLSpec } from './types';
2
- export declare function getSpecByTagName(tagName: string, specs: MLMLSpec): MLDOMElementSpec | null;
1
+ import type { MLDOMElementSpec, MLMLSpec } from './types';
2
+ export declare function getSpecByTagName(nameWithNS: string, specs: MLMLSpec): MLDOMElementSpec | null;
@@ -16,9 +16,8 @@ function getSpecOM({ specs }) {
16
16
  }
17
17
  return som;
18
18
  }
19
- function getSpecByTagName(tagName, specs) {
19
+ function getSpecByTagName(nameWithNS, specs) {
20
20
  const specOM = getSpecOM(specs);
21
- tagName = tagName.toLowerCase();
22
- return specOM[tagName] || null;
21
+ return specOM[nameWithNS] || null;
23
22
  }
24
23
  exports.getSpecByTagName = getSpecByTagName;
package/lib/get-spec.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ElementSpec, ExtendedSpec, MLMLSpec } from '@markuplint/ml-spec';
1
+ import type { ElementSpec, ExtendedSpec, MLMLSpec } from './types';
2
2
  /**
3
3
  * Merging HTML-spec schema and extended spec schemas
4
4
  *
@@ -7,7 +7,7 @@ import { ElementSpec, ExtendedSpec, MLMLSpec } from '@markuplint/ml-spec';
7
7
  * @param schemas `MLDocument.schemas`
8
8
  */
9
9
  export declare function getSpec(schemas: readonly [MLMLSpec, ...ExtendedSpec[]]): {
10
- cites: import("@markuplint/ml-spec").Cites;
11
- def: import("@markuplint/ml-spec").SpecDefs;
10
+ cites: import("./types").Cites;
11
+ def: import("./types").SpecDefs;
12
12
  specs: ElementSpec[];
13
13
  };
package/lib/get-spec.js CHANGED
@@ -10,8 +10,9 @@ const utils_1 = require("./utils");
10
10
  * @param schemas `MLDocument.schemas`
11
11
  */
12
12
  function getSpec(schemas) {
13
+ var _a, _b, _c;
13
14
  const [main, ...extendedSpecs] = schemas;
14
- const result = Object.assign({}, main);
15
+ const result = { ...main };
15
16
  for (const extendedSpec of extendedSpecs) {
16
17
  if (extendedSpec.cites) {
17
18
  result.cites = [...result.cites, ...extendedSpec.cites];
@@ -20,8 +21,11 @@ function getSpec(schemas) {
20
21
  if (extendedSpec.def['#ariaAttrs']) {
21
22
  result.def['#ariaAttrs'] = [...result.def['#ariaAttrs'], ...extendedSpec.def['#ariaAttrs']];
22
23
  }
23
- if (extendedSpec.def['#globalAttrs']) {
24
- result.def['#globalAttrs'] = [...result.def['#globalAttrs'], ...extendedSpec.def['#globalAttrs']];
24
+ if ((_a = extendedSpec.def['#globalAttrs']) === null || _a === void 0 ? void 0 : _a['#extends']) {
25
+ result.def['#globalAttrs']['#HTMLGlobalAttrs'] = [
26
+ ...(((_b = result.def['#globalAttrs']) === null || _b === void 0 ? void 0 : _b['#HTMLGlobalAttrs']) || []),
27
+ ...(((_c = extendedSpec.def['#globalAttrs']) === null || _c === void 0 ? void 0 : _c['#extends']) || []),
28
+ ];
25
29
  }
26
30
  if (extendedSpec.def['#roles']) {
27
31
  result.def['#roles'] = [...result.def['#roles'], ...extendedSpec.def['#roles']];
@@ -49,7 +53,12 @@ function getSpec(schemas) {
49
53
  continue;
50
54
  }
51
55
  const exSpec = exSpecs.splice(index, 1)[0];
52
- specs.push(Object.assign(Object.assign(Object.assign({}, elSpec), exSpec), { attributes: utils_1.mergeArray(elSpec.attributes, exSpec.attributes), categories: utils_1.mergeArray(elSpec.categories, exSpec.categories) }));
56
+ specs.push({
57
+ ...elSpec,
58
+ ...exSpec,
59
+ attributes: (0, utils_1.mergeArray)(elSpec.attributes, exSpec.attributes),
60
+ categories: (0, utils_1.mergeArray)(elSpec.categories, exSpec.categories),
61
+ });
53
62
  }
54
63
  result.specs = specs;
55
64
  }
package/lib/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from './permitted-structres';
2
+ export * from './attributes';
2
3
  export * from './get-spec-by-tag-name';
3
4
  export * from './get-spec';
5
+ export * from './get-ns';
4
6
  export * from './types';
package/lib/index.js CHANGED
@@ -1,16 +1,9 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
2
  Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./permitted-structres"), exports);
14
- __exportStar(require("./get-spec-by-tag-name"), exports);
15
- __exportStar(require("./get-spec"), exports);
16
- __exportStar(require("./types"), exports);
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./permitted-structres"), exports);
5
+ (0, tslib_1.__exportStar)(require("./attributes"), exports);
6
+ (0, tslib_1.__exportStar)(require("./get-spec-by-tag-name"), exports);
7
+ (0, tslib_1.__exportStar)(require("./get-spec"), exports);
8
+ (0, tslib_1.__exportStar)(require("./get-ns"), exports);
9
+ (0, tslib_1.__exportStar)(require("./types"), exports);
@@ -6,7 +6,7 @@
6
6
  export declare type PermittedContent = PermittedContentRequire | PermittedContentOptional | PermittedContentOneOrMore | PermittedContentZeroOrMore | PermittedContentChoice | PermittedContentInterleave;
7
7
  export declare type Target = Node | Node[];
8
8
  export declare type Node = string | '#text' | ContentModel;
9
- export declare type ContentModel = '#phrasing' | '#flow' | '#interactive' | '#heading' | '#sectioning' | '#metadata' | '#transparent' | '#embedded' | '#palpable' | '#script-supporting';
9
+ export declare type ContentModel = '#phrasing' | '#flow' | '#interactive' | '#heading' | '#sectioning' | '#metadata' | '#transparent' | '#embedded' | '#palpable' | '#script-supporting' | '#SVGAnimation' | '#SVGBasicShapes' | '#SVGContainer' | '#SVGDescriptive' | '#SVGFilterPrimitive' | '#SVGFont' | '#SVGGradient' | '#SVGGraphics' | '#SVGGraphicsReferencing' | '#SVGLightSource' | '#SVGNeverRendered' | '#SVGNone' | '#SVGPaintServer' | '#SVGRenderable' | '#SVGShape' | '#SVGStructural' | '#SVGStructurallyExternal' | '#SVGTextContent' | '#SVGTextContentChild' | '#SVGOtherXMLNamespace';
10
10
  export declare type PermittedContentSpec = PermittedContent[];
11
11
  export interface PermittedStructuresSchema {
12
12
  summary?: string;
package/lib/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { ContentModel, PermittedStructuresSchema } from './permitted-structres';
1
+ import type { AttributeCondition, AttributeType } from './attributes';
2
+ import type { ContentModel, PermittedStructuresSchema } from './permitted-structres';
2
3
  /**
3
4
  * markuplit Markup-language spec
4
5
  */
@@ -20,9 +21,13 @@ export declare type ExtendedSpec = {
20
21
  */
21
22
  export declare type Cites = string[];
22
23
  export declare type SpecDefs = {
23
- '#globalAttrs': Attribute[];
24
- '#roles': ARIRRoleAttribute[];
24
+ '#globalAttrs': Partial<{
25
+ '#extends': Attribute[];
26
+ '#HTMLGlobalAttrs': Attribute[];
27
+ [OtherGlobalAttrs: string]: Attribute[];
28
+ }>;
25
29
  '#ariaAttrs': ARIAAttribute[];
30
+ '#roles': ARIRRoleAttribute[];
26
31
  '#contentModels': {
27
32
  [model in ContentModel]?: string[];
28
33
  };
@@ -35,6 +40,11 @@ export declare type ElementSpec = {
35
40
  * Tag name
36
41
  */
37
42
  name: string;
43
+ /**
44
+ * Namespaces in XML
45
+ * @see https://www.w3.org/TR/xml-names/
46
+ */
47
+ namespace?: 'http://www.w3.org/1999/xhtml' | 'http://www.w3.org/2000/svg' | 'http://www.w3.org/1998/Math/MathML';
38
48
  /**
39
49
  * Reference URL
40
50
  */
@@ -119,24 +129,18 @@ declare type ElementCondition = {
119
129
  };
120
130
  export declare type Attribute = {
121
131
  name: string;
122
- type: AttributeType;
132
+ type: AttributeType | [AttributeType, ...AttributeType[]];
123
133
  description: string;
124
134
  caseSensitive?: true;
125
135
  experimental?: true;
126
136
  obsolete?: true;
127
- deprecated?: true;
137
+ deprecated?: boolean;
128
138
  nonStandard?: true;
129
- required?: true | AttributeCondition;
139
+ required?: boolean | AttributeCondition;
130
140
  requiredEither?: string[];
131
- enum?: string[];
132
141
  noUse?: boolean;
133
142
  condition?: AttributeCondition;
134
143
  };
135
- export declare type AttributeCondition = {
136
- ancestor?: string;
137
- self?: string | string[];
138
- };
139
- export declare type AttributeType = 'String' | 'NonEmptyString' | 'Boolean' | 'Function' | 'Date' | 'Int' | 'Uint' | 'Float' | 'NonZeroUint' | 'AcceptList' | 'AutoComplete' | 'BCP47' | 'Color' | 'ColSpan' | 'Coords' | 'DateTime' | 'Destination' | 'DOMID' | 'DOMIDList' | 'ItemType' | 'LinkSizes' | 'LinkType' | 'LinkTypeList' | 'MediaQuery' | 'MediaQueryList' | 'MIMEType' | 'ReferrerPolicy' | 'RowSpan' | 'SourceSizeList' | 'SrcSet' | 'TabIndex' | 'Target' | 'URL' | 'URLHash' | 'URLList';
140
144
  export declare type ARIRRoleAttribute = {
141
145
  name: string;
142
146
  description: string;
@@ -163,10 +167,21 @@ export declare type ARIAAttribute = {
163
167
  deprecated?: true;
164
168
  isGlobal?: true;
165
169
  value: ARIAAttributeValue;
170
+ conditionalValue?: {
171
+ role: string[];
172
+ value: ARIAAttributeValue;
173
+ }[];
166
174
  enum: string[];
167
175
  defaultValue?: string;
176
+ equivalentHtmlAttrs?: EquivalentHtmlAttr[];
177
+ valueDescriptions?: Record<string, string>;
168
178
  };
169
179
  export declare type ARIAAttributeValue = 'true/false' | 'tristate' | 'true/false/undefined' | 'ID reference' | 'ID reference list' | 'integer' | 'number' | 'string' | 'token' | 'token list' | 'URI';
180
+ export declare type EquivalentHtmlAttr = {
181
+ htmlAttrName: string;
182
+ isNotStrictEquivalent?: true;
183
+ value: string | null;
184
+ };
170
185
  export interface SpecOM {
171
186
  [tagName: string]: MLDOMElementSpec;
172
187
  }
package/lib/utils.js CHANGED
@@ -21,7 +21,10 @@ function mergeArray(a, b) {
21
21
  result.push(bItem);
22
22
  continue;
23
23
  }
24
- const exItem = Object.assign(Object.assign({}, aItem), bItem);
24
+ const exItem = {
25
+ ...aItem,
26
+ ...bItem,
27
+ };
25
28
  result.push(exItem);
26
29
  }
27
30
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/ml-spec",
3
- "version": "1.5.0",
3
+ "version": "2.0.0-dev.26+6a10aede",
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>",
@@ -15,11 +15,15 @@
15
15
  "build": "tsc",
16
16
  "dev": "tsc --build --watch",
17
17
  "clean": "tsc --build --clean",
18
- "schema": "json2ts ./schemas/permitted-structures.schema.json > ./src/permitted-structres.ts; prettier --write ./src/permitted-structres.ts; eslint --fix --config ../../../.eslintrc ./src/permitted-structres.ts"
18
+ "schema:structures": "json2ts ./schemas/permitted-structures.schema.json > ./src/permitted-structres.ts; prettier --write ./src/permitted-structres.ts; eslint --fix --config ../../../.eslintrc ./src/permitted-structres.ts",
19
+ "schema:attributes": "json2ts ./schemas/attributes.schema.json > ./src/attributes.ts; prettier --write ./src/attributes.ts; eslint --fix --config ../../../.eslintrc ./src/attributes.ts",
20
+ "schema": "yarn schema:structures; yarn schema:attributes;"
21
+ },
22
+ "dependencies": {
23
+ "tslib": "^2.3.1"
19
24
  },
20
25
  "devDependencies": {
21
- "json-schema-to-typescript": "^10.1.3",
22
- "typescript-json-schema": "^0.48.0"
26
+ "json-schema-to-typescript": "^10.1.5"
23
27
  },
24
- "gitHead": "361f6e18dbeb369e769e3b1ae8c97a006452938d"
28
+ "gitHead": "6a10aede7385e2e97d0ba2c272a2e8c08e5429fd"
25
29
  }
@@ -1,25 +1,192 @@
1
1
  {
2
2
  "definitions": {
3
- "condition": {
3
+ "AttributeCondition": {
4
4
  "oneOf": [
5
5
  {
6
6
  "type": "object",
7
7
  "additionalProperties": false,
8
+ "required": ["ancestor"],
8
9
  "properties": {
9
- "ancestor": { "type": "string" }
10
+ "ancestor": {
11
+ "type": "string"
12
+ }
10
13
  }
11
14
  },
12
15
  {
13
16
  "type": "object",
14
17
  "additionalProperties": false,
18
+ "required": ["self"],
15
19
  "properties": {
16
20
  "self": {
17
21
  "type": ["string", "array"],
18
- "items": { "type": "string", "minItems": 2 }
22
+ "items": {
23
+ "type": "string",
24
+ "minItems": 2
25
+ }
19
26
  }
20
27
  }
21
28
  }
22
29
  ]
30
+ },
31
+ "AttributeType": {
32
+ "oneOf": [
33
+ {
34
+ "type": "string",
35
+ "enum": [
36
+ "String",
37
+ "NonEmptyString",
38
+ "Boolean",
39
+ "Function",
40
+ "Date",
41
+ "Int",
42
+ "Uint",
43
+ "Float",
44
+ "NonZeroUint",
45
+ "ZeroToOne",
46
+ "AcceptList",
47
+ "AutoComplete",
48
+ "BCP47",
49
+ "Color",
50
+ "ColSpan",
51
+ "Coords",
52
+ "Crossorigin",
53
+ "DateTime",
54
+ "Destination",
55
+ "DOMID",
56
+ "DOMIDList",
57
+ "IRI",
58
+ "ItemType",
59
+ "LinkSizes",
60
+ "LinkType",
61
+ "LinkTypeList",
62
+ "MediaQuery",
63
+ "MediaQueryList",
64
+ "MIMEType",
65
+ "ReferrerPolicy",
66
+ "RowSpan",
67
+ "SourceSizeList",
68
+ "SrcSet",
69
+ "TabIndex",
70
+ "Target",
71
+ "URL",
72
+ "URLHash",
73
+ "URLList",
74
+ "CSSAngle",
75
+ "CSSBlendMode",
76
+ "CSSClipPath",
77
+ "CSSCustomIdent",
78
+ "CSSDisplay",
79
+ "CSSFilter",
80
+ "CSSFontFamily",
81
+ "CSSFontSize",
82
+ "CSSFontVariant",
83
+ "CSSFontWeight",
84
+ "CSSMask",
85
+ "CSSOpacity",
86
+ "CSSTextDecoration",
87
+ "CSSTransformList",
88
+ "CSSTransformOrigin",
89
+ "CSSURL",
90
+ "SVGAnimatableValue",
91
+ "SVGBeginValueList",
92
+ "SVGClockValue",
93
+ "SVGColorMatrix",
94
+ "SVGDashArray",
95
+ "SVGEndValueList",
96
+ "SVGFilterPrimitiveReference",
97
+ "SVGKernelMatrix",
98
+ "SVGKeyPoints",
99
+ "SVGKeySplines",
100
+ "SVGKeyTimes",
101
+ "SVGLanguageTags",
102
+ "SVGLength",
103
+ "SVGLengthList",
104
+ "SVGNumberList",
105
+ "SVGNumberOptionalNumber",
106
+ "SVGOrigin",
107
+ "SVGPaint",
108
+ "SVGPathCommands",
109
+ "SVGPercentage",
110
+ "SVGPercentageList",
111
+ "SVGPoints",
112
+ "SVGPreserveAspectRatio",
113
+ "SVGViewBox"
114
+ ]
115
+ },
116
+ {
117
+ "type": "object",
118
+ "additionalProperties": false,
119
+ "required": ["enum"],
120
+ "properties": {
121
+ "enum": {
122
+ "type": "array",
123
+ "minLength": 1,
124
+ "uniqueItems": true,
125
+ "items": {
126
+ "type": "string"
127
+ }
128
+ }
129
+ }
130
+ }
131
+ ]
132
+ },
133
+ "AttributeJSON": {
134
+ "type": "object",
135
+ "additionalProperties": false,
136
+ "required": ["name", "type"],
137
+ "properties": {
138
+ "name": {
139
+ "type": "string"
140
+ },
141
+ "type": {
142
+ "oneOf": [
143
+ {
144
+ "$ref": "#/definitions/AttributeType"
145
+ },
146
+ {
147
+ "type": "array",
148
+ "minItems": 1,
149
+ "uniqueItems": true,
150
+ "items": {
151
+ "$ref": "#/definitions/AttributeType"
152
+ }
153
+ }
154
+ ]
155
+ },
156
+ "defaultValue": { "type": "string" },
157
+ "deprecated": { "type": "boolean" },
158
+ "required": {
159
+ "oneOf": [
160
+ {
161
+ "type": "boolean"
162
+ },
163
+ {
164
+ "$ref": "#/definitions/AttributeCondition"
165
+ }
166
+ ]
167
+ },
168
+ "requiredEither": {
169
+ "type": "array",
170
+ "items": {
171
+ "type": "string"
172
+ }
173
+ },
174
+ "noUse": {
175
+ "type": "boolean"
176
+ },
177
+ "condition": {
178
+ "$ref": "#/definitions/AttributeCondition"
179
+ }
180
+ }
181
+ },
182
+ "DefineDefaultAttributeType": {
183
+ "type": "object",
184
+ "additionalProperties": false,
185
+ "required": ["name", "defaultValue"],
186
+ "properties": {
187
+ "name": { "type": "string" },
188
+ "defaultValue": { "type": "string" }
189
+ }
23
190
  }
24
191
  },
25
192
  "type": "object",
@@ -29,65 +196,39 @@
29
196
  "tag": { "type": "string" },
30
197
  "attributes": {
31
198
  "type": "array",
199
+ "uniqueItems": true,
32
200
  "items": {
33
- "type": "object",
34
- "additionalProperties": false,
35
- "required": ["name", "type"],
36
- "properties": {
37
- "name": { "type": "string" },
38
- "type": {
201
+ "anyOf": [
202
+ {
39
203
  "type": "string",
40
204
  "enum": [
41
- "String",
42
- "NonEmptyString",
43
- "Boolean",
44
- "Function", // JavaScript function body
45
- "Date",
46
- "Int", // Integer
47
- "Uint", // Non-negative integer
48
- "Float", // Floating-point number
49
- "NonZeroUint", // Non-negative integer greater than zero
50
- "AcceptList", // https://html.spec.whatwg.org/multipage/input.html#attr-input-accept
51
- "AutoComplete", // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-detail-tokens
52
- "BCP47", // https://tools.ietf.org/html/bcp47
53
- "Color", // https://drafts.csswg.org/css-color/#typedef-color
54
- "ColSpan", // https://html.spec.whatwg.org/multipage/tables.html#attr-tdth-colspan
55
- "Coords", // https://html.spec.whatwg.org/multipage/image-maps.html#attr-area-coords
56
- "DateTime", // https://html.spec.whatwg.org/multipage/text-level-semantics.html#datetime-value
57
- "Destination", // https://html.spec.whatwg.org/multipage/semantics.html#attr-link-as
58
- "DOMID",
59
- "DOMIDList",
60
- "ItemType", // https://html.spec.whatwg.org/multipage/microdata.html#attr-itemtype
61
- "LinkSizes", // https://html.spec.whatwg.org/multipage/semantics.html#attr-link-sizes
62
- "LinkType", // https://html.spec.whatwg.org/multipage/links.html#linkTypes
63
- "LinkTypeList", // https://html.spec.whatwg.org/multipage/links.html#linkTypes
64
- "MediaQuery", // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-media-query-list
65
- "MediaQueryList", // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-media-query-list
66
- "MIMEType", // https://mimesniff.spec.whatwg.org/#valid-mime-type
67
- "ReferrerPolicy", // https://html.spec.whatwg.org/multipage/urls-and-fetching.html#referrer-policy-attribute
68
- "RowSpan", // https://html.spec.whatwg.org/multipage/tables.html#attr-tdth-rowspan
69
- "SourceSizeList", // https://html.spec.whatwg.org/multipage/images.html#sizes-attributes
70
- "SrcSet", // https://html.spec.whatwg.org/multipage/images.html#srcset-attribute
71
- "TabIndex", // https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex
72
- "Target", // https://html.spec.whatwg.org/multipage/links.html#attr-hyperlink-target
73
- "URL", // https://html.spec.whatwg.org/multipage/urls-and-fetching.html#valid-url-potentially-surrounded-by-spaces
74
- "URLHash", // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-hash-name-reference
75
- "URLList" // https://html.spec.whatwg.org/multipage/urls-and-fetching.html#valid-url-potentially-surrounded-by-spaces
205
+ "#globalAttrs",
206
+ "#ariaAttrs",
207
+ "#SVGAnimationAdditionAttrs",
208
+ "#SVGAnimationAttributeTargetAttrs",
209
+ "#SVGAnimationEventAttrs",
210
+ "#SVGAnimationTargetElementAttrs",
211
+ "#SVGAnimationTimingAttrs",
212
+ "#SVGAnimationValueAttrs",
213
+ "#SVGConditionalProcessingAttrs",
214
+ "#SVGCoreAttrs",
215
+ "#SVGDocumentElementEventAttrs",
216
+ "#SVGDocumentEventAttrs",
217
+ "#SVGFilterPrimitiveAttrs",
218
+ "#SVGGlobalEventAttrs",
219
+ "#SVGGraphicalEventAttrs",
220
+ "#SVGPresentationAttrs",
221
+ "#SVGTransferFunctionAttrs",
222
+ "#XLinkAttrs"
76
223
  ]
77
224
  },
78
- "deprecated": { "type": "boolean" },
79
- "required": {
80
- "oneOf": [{ "type": "boolean" }, { "$ref": "#/definitions/condition" }]
81
- },
82
- "requiredEither": { "type": "array", "items": { "type": "string" } },
83
- "enum": { "type": "array", "items": { "type": "string" }, "minLength": 1 },
84
- "noUse": {
85
- "type": "boolean"
225
+ {
226
+ "$ref": "#/definitions/AttributeJSON"
86
227
  },
87
- "condition": {
88
- "$ref": "#/definitions/condition"
228
+ {
229
+ "$ref": "#/definitions/DefineDefaultAttributeType"
89
230
  }
90
- }
231
+ ]
91
232
  }
92
233
  }
93
234
  }
@@ -0,0 +1,12 @@
1
+ {
2
+ "type": "object",
3
+ "additionalProperties": false,
4
+ "patternProperties": {
5
+ "^#[a-zA-Z]+Attrs$": {
6
+ "type": "array",
7
+ "items": {
8
+ "$ref": "./attributes.schema.json#/definitions/AttributeJSON"
9
+ }
10
+ }
11
+ }
12
+ }