@markuplint/ml-core 4.0.0-alpha.1 → 4.0.0-alpha.3
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/lib/configs.js +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/ml-dom/node/document.d.ts +3 -1
- package/lib/ml-dom/node/document.js +44 -1
- package/lib/ml-dom/node/element.d.ts +33 -0
- package/lib/ml-dom/node/element.js +43 -0
- package/lib/ml-dom/node/types.d.ts +14 -0
- package/package.json +14 -14
package/lib/configs.js
CHANGED
|
@@ -31,6 +31,7 @@ async function forceImportJsonInModule(modPath) {
|
|
|
31
31
|
.replace(/^[\\/][a-z]:/i, '');
|
|
32
32
|
log('Find JSON file path: %s', normalizePath);
|
|
33
33
|
const fileContent = await readFile(normalizePath, { encoding: 'utf8' });
|
|
34
|
+
log('Success to read JSON file path: %s', normalizePath);
|
|
34
35
|
return JSON.parse(fileContent);
|
|
35
36
|
}
|
|
36
37
|
return error.default ? error.default : error;
|
package/lib/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { MLDocumentType } from './document-type.js';
|
|
|
4
4
|
import type { MLElement } from './element.js';
|
|
5
5
|
import type { MLNode } from './node.js';
|
|
6
6
|
import type { MLText } from './text.js';
|
|
7
|
-
import type { DocumentNodeType } from './types.js';
|
|
7
|
+
import type { AccessibilityProperties, DocumentNodeType } from './types.js';
|
|
8
8
|
import type { MLRule } from '../../ml-rule/index.js';
|
|
9
9
|
import type Ruleset from '../../ruleset/index.js';
|
|
10
10
|
import type { MLSchema } from '../../types.js';
|
|
@@ -933,6 +933,7 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
|
|
|
933
933
|
* @implements DOM API: `Document`
|
|
934
934
|
*/
|
|
935
935
|
get onscroll(): ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
936
|
+
get onscrollend(): ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
936
937
|
/**
|
|
937
938
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
938
939
|
*
|
|
@@ -1428,6 +1429,7 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
|
|
|
1428
1429
|
* @implements DOM API: `Document`
|
|
1429
1430
|
*/
|
|
1430
1431
|
exitPointerLock(): void;
|
|
1432
|
+
getAccessibilityProp(node: MLNode<T, O>, ariaVersion?: "1.2"): AccessibilityProperties | null;
|
|
1431
1433
|
/**
|
|
1432
1434
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1433
1435
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var _MLDocument_filename, _MLDocument_tokenList;
|
|
2
2
|
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
3
|
import { exchangeValueOnRule, mergeRule } from '@markuplint/ml-config';
|
|
4
|
-
import { schemaToSpec } from '@markuplint/ml-spec';
|
|
4
|
+
import { schemaToSpec, getAccname, getComputedRole, mayBeFocusable, getComputedAriaProps, isExposed, ARIA_RECOMMENDED_VERSION, } from '@markuplint/ml-spec';
|
|
5
5
|
import { ConfigParserError } from '@markuplint/parser-utils';
|
|
6
6
|
import { InvalidSelectorError, matchSelector } from '@markuplint/selector';
|
|
7
7
|
import { log as coreLog } from '../../debug.js';
|
|
@@ -1170,6 +1170,9 @@ export class MLDocument extends MLParentNode {
|
|
|
1170
1170
|
get onscroll() {
|
|
1171
1171
|
throw new UnexpectedCallError('Not supported "onscroll" property');
|
|
1172
1172
|
}
|
|
1173
|
+
get onscrollend() {
|
|
1174
|
+
throw new UnexpectedCallError('Not supported "onscrollend" property');
|
|
1175
|
+
}
|
|
1173
1176
|
/**
|
|
1174
1177
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1175
1178
|
*
|
|
@@ -1821,6 +1824,46 @@ export class MLDocument extends MLParentNode {
|
|
|
1821
1824
|
exitPointerLock() {
|
|
1822
1825
|
throw new UnexpectedCallError('Not supported "exitPointerLock" method');
|
|
1823
1826
|
}
|
|
1827
|
+
getAccessibilityProp(
|
|
1828
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
1829
|
+
node, ariaVersion = ARIA_RECOMMENDED_VERSION) {
|
|
1830
|
+
if (!node.is(node.ELEMENT_NODE)) {
|
|
1831
|
+
return null;
|
|
1832
|
+
}
|
|
1833
|
+
const exposed = isExposed(node, node.ownerMLDocument.specs, ariaVersion);
|
|
1834
|
+
if (!exposed) {
|
|
1835
|
+
return {
|
|
1836
|
+
exposedToTree: false,
|
|
1837
|
+
};
|
|
1838
|
+
}
|
|
1839
|
+
const aria = {
|
|
1840
|
+
exposedToTree: true,
|
|
1841
|
+
};
|
|
1842
|
+
const role = getComputedRole(node.ownerMLDocument.specs, node, ariaVersion);
|
|
1843
|
+
const name = getAccname(node).trim();
|
|
1844
|
+
const focusable = mayBeFocusable(node, node.ownerMLDocument.specs);
|
|
1845
|
+
const nameRequired = role.role?.accessibleNameRequired ?? false;
|
|
1846
|
+
const nameProhibited = role.role?.accessibleNameProhibited ?? false;
|
|
1847
|
+
aria.role = role.role?.name;
|
|
1848
|
+
aria.nameRequired = nameRequired;
|
|
1849
|
+
aria.nameProhibited = nameProhibited;
|
|
1850
|
+
aria.name = name;
|
|
1851
|
+
aria.focusable = focusable;
|
|
1852
|
+
Object.values(getComputedAriaProps(node.ownerMLDocument.specs, node, ariaVersion)).forEach(prop => {
|
|
1853
|
+
if (!prop.required) {
|
|
1854
|
+
if (prop.from === 'default') {
|
|
1855
|
+
return;
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
aria.props = aria.props || {};
|
|
1859
|
+
const propName = prop.name.replace('aria-', '');
|
|
1860
|
+
aria.props[propName] = {
|
|
1861
|
+
value: prop.value ?? null,
|
|
1862
|
+
required: prop.required,
|
|
1863
|
+
};
|
|
1864
|
+
});
|
|
1865
|
+
return aria;
|
|
1866
|
+
}
|
|
1824
1867
|
/**
|
|
1825
1868
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1826
1869
|
*
|
|
@@ -1165,6 +1165,7 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
|
|
|
1165
1165
|
* @implements DOM API: `Element`
|
|
1166
1166
|
*/
|
|
1167
1167
|
get onscroll(): ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
1168
|
+
get onscrollend(): ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
1168
1169
|
/**
|
|
1169
1170
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1170
1171
|
*
|
|
@@ -1373,6 +1374,14 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
|
|
|
1373
1374
|
* @see https://www.w3.org/TR/css-shadow-parts-1/#idl
|
|
1374
1375
|
*/
|
|
1375
1376
|
get part(): DOMTokenList;
|
|
1377
|
+
/**
|
|
1378
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1379
|
+
*
|
|
1380
|
+
* @unsupported
|
|
1381
|
+
* @implements DOM API: `Element`
|
|
1382
|
+
* @see https://html.spec.whatwg.org/multipage/popover.html#dom-popover
|
|
1383
|
+
*/
|
|
1384
|
+
get popover(): string | null;
|
|
1376
1385
|
/**
|
|
1377
1386
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1378
1387
|
*
|
|
@@ -1720,6 +1729,14 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
|
|
|
1720
1729
|
* @see https://www.w3.org/TR/pointerevents2/#dom-element-haspointercapture
|
|
1721
1730
|
*/
|
|
1722
1731
|
hasPointerCapture(pointerId: number): boolean;
|
|
1732
|
+
/**
|
|
1733
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1734
|
+
*
|
|
1735
|
+
* @unsupported
|
|
1736
|
+
* @implements DOM API: `Element`
|
|
1737
|
+
* @see https://html.spec.whatwg.org/multipage/popover.html#dom-hidepopover
|
|
1738
|
+
*/
|
|
1739
|
+
hidePopover(): void;
|
|
1723
1740
|
/**
|
|
1724
1741
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1725
1742
|
*
|
|
@@ -1889,6 +1906,14 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
|
|
|
1889
1906
|
* @see https://www.w3.org/TR/pointerevents2/#idl-def-element-setpointercapture-pointerid
|
|
1890
1907
|
*/
|
|
1891
1908
|
setPointerCapture(pointerId: number): void;
|
|
1909
|
+
/**
|
|
1910
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1911
|
+
*
|
|
1912
|
+
* @unsupported
|
|
1913
|
+
* @implements DOM API: `Element`
|
|
1914
|
+
* @see https://html.spec.whatwg.org/multipage/popover.html#dom-showpopover
|
|
1915
|
+
*/
|
|
1916
|
+
showPopover(): void;
|
|
1892
1917
|
/**
|
|
1893
1918
|
* @implements `@markuplint/ml-core` API: `MLElement`
|
|
1894
1919
|
*/
|
|
@@ -1905,6 +1930,14 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
|
|
|
1905
1930
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-toggleattribute%E2%91%A0
|
|
1906
1931
|
*/
|
|
1907
1932
|
toggleAttribute(qualifiedName: string, force?: boolean): boolean;
|
|
1933
|
+
/**
|
|
1934
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1935
|
+
*
|
|
1936
|
+
* @unsupported
|
|
1937
|
+
* @implements DOM API: `Element`
|
|
1938
|
+
* @see https://html.spec.whatwg.org/multipage/popover.html#dom-togglepopover
|
|
1939
|
+
*/
|
|
1940
|
+
togglePopover(force?: boolean): void;
|
|
1908
1941
|
/**
|
|
1909
1942
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1910
1943
|
*
|
|
@@ -1506,6 +1506,9 @@ export class MLElement extends MLParentNode {
|
|
|
1506
1506
|
get onscroll() {
|
|
1507
1507
|
throw new UnexpectedCallError('Not supported "onscroll" property');
|
|
1508
1508
|
}
|
|
1509
|
+
get onscrollend() {
|
|
1510
|
+
throw new UnexpectedCallError('Not supported "onscrollend" property');
|
|
1511
|
+
}
|
|
1509
1512
|
/**
|
|
1510
1513
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1511
1514
|
*
|
|
@@ -1766,6 +1769,16 @@ export class MLElement extends MLParentNode {
|
|
|
1766
1769
|
get part() {
|
|
1767
1770
|
throw new UnexpectedCallError('Not supported "part" property');
|
|
1768
1771
|
}
|
|
1772
|
+
/**
|
|
1773
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1774
|
+
*
|
|
1775
|
+
* @unsupported
|
|
1776
|
+
* @implements DOM API: `Element`
|
|
1777
|
+
* @see https://html.spec.whatwg.org/multipage/popover.html#dom-popover
|
|
1778
|
+
*/
|
|
1779
|
+
get popover() {
|
|
1780
|
+
throw new UnexpectedCallError('Not supported "popover" property');
|
|
1781
|
+
}
|
|
1769
1782
|
/**
|
|
1770
1783
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1771
1784
|
*
|
|
@@ -2337,6 +2350,16 @@ export class MLElement extends MLParentNode {
|
|
|
2337
2350
|
hasPointerCapture(pointerId) {
|
|
2338
2351
|
throw new UnexpectedCallError('Not supported "hasPointerCapture" method');
|
|
2339
2352
|
}
|
|
2353
|
+
/**
|
|
2354
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2355
|
+
*
|
|
2356
|
+
* @unsupported
|
|
2357
|
+
* @implements DOM API: `Element`
|
|
2358
|
+
* @see https://html.spec.whatwg.org/multipage/popover.html#dom-hidepopover
|
|
2359
|
+
*/
|
|
2360
|
+
hidePopover() {
|
|
2361
|
+
throw new UnexpectedCallError('Not supported "hidePopover" method');
|
|
2362
|
+
}
|
|
2340
2363
|
/**
|
|
2341
2364
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2342
2365
|
*
|
|
@@ -2678,6 +2701,16 @@ export class MLElement extends MLParentNode {
|
|
|
2678
2701
|
setPointerCapture(pointerId) {
|
|
2679
2702
|
throw new UnexpectedCallError('Not supported "setPointerCapture" method');
|
|
2680
2703
|
}
|
|
2704
|
+
/**
|
|
2705
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2706
|
+
*
|
|
2707
|
+
* @unsupported
|
|
2708
|
+
* @implements DOM API: `Element`
|
|
2709
|
+
* @see https://html.spec.whatwg.org/multipage/popover.html#dom-showpopover
|
|
2710
|
+
*/
|
|
2711
|
+
showPopover() {
|
|
2712
|
+
throw new UnexpectedCallError('Not supported "showPopover" method');
|
|
2713
|
+
}
|
|
2681
2714
|
/**
|
|
2682
2715
|
* @implements `@markuplint/ml-core` API: `MLElement`
|
|
2683
2716
|
*/
|
|
@@ -2716,6 +2749,16 @@ export class MLElement extends MLParentNode {
|
|
|
2716
2749
|
toggleAttribute(qualifiedName, force) {
|
|
2717
2750
|
throw new UnexpectedCallError('Not supported "toggleAttribute" method');
|
|
2718
2751
|
}
|
|
2752
|
+
/**
|
|
2753
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2754
|
+
*
|
|
2755
|
+
* @unsupported
|
|
2756
|
+
* @implements DOM API: `Element`
|
|
2757
|
+
* @see https://html.spec.whatwg.org/multipage/popover.html#dom-togglepopover
|
|
2758
|
+
*/
|
|
2759
|
+
togglePopover(force) {
|
|
2760
|
+
throw new UnexpectedCallError('Not supported "togglePopover" method');
|
|
2761
|
+
}
|
|
2719
2762
|
/**
|
|
2720
2763
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2721
2764
|
*
|
|
@@ -33,3 +33,17 @@ export type PretenderContextPretended<N extends MLElement<T, O>, T extends RuleC
|
|
|
33
33
|
readonly type: 'origin';
|
|
34
34
|
readonly origin: N;
|
|
35
35
|
};
|
|
36
|
+
export type AccessibilityProperties = {
|
|
37
|
+
exposedToTree: boolean;
|
|
38
|
+
role?: string;
|
|
39
|
+
roleDescription?: string;
|
|
40
|
+
name?: string;
|
|
41
|
+
nameRequired?: boolean;
|
|
42
|
+
nameProhibited?: boolean;
|
|
43
|
+
focusable?: boolean;
|
|
44
|
+
props?: Record<string, AccessibilityProperty>;
|
|
45
|
+
};
|
|
46
|
+
export type AccessibilityProperty = {
|
|
47
|
+
value: string | null;
|
|
48
|
+
required: boolean;
|
|
49
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/ml-core",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.3",
|
|
4
4
|
"description": "The core module of markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -28,20 +28,20 @@
|
|
|
28
28
|
"./lib/configs.js": "./lib/configs.browser.js"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@markuplint/config-presets": "4.0.0-alpha.
|
|
32
|
-
"@markuplint/html-parser": "4.0.0-alpha.
|
|
33
|
-
"@markuplint/html-spec": "4.0.0-alpha.
|
|
34
|
-
"@markuplint/i18n": "4.0.0-alpha.
|
|
35
|
-
"@markuplint/ml-ast": "4.0.0-alpha.
|
|
36
|
-
"@markuplint/ml-config": "4.0.0-alpha.
|
|
37
|
-
"@markuplint/ml-spec": "4.0.0-alpha.
|
|
38
|
-
"@markuplint/parser-utils": "4.0.0-alpha.
|
|
39
|
-
"@markuplint/selector": "4.0.0-alpha.
|
|
40
|
-
"@types/debug": "^4.1.
|
|
31
|
+
"@markuplint/config-presets": "4.0.0-alpha.3",
|
|
32
|
+
"@markuplint/html-parser": "4.0.0-alpha.3",
|
|
33
|
+
"@markuplint/html-spec": "4.0.0-alpha.3",
|
|
34
|
+
"@markuplint/i18n": "4.0.0-alpha.3",
|
|
35
|
+
"@markuplint/ml-ast": "4.0.0-alpha.3",
|
|
36
|
+
"@markuplint/ml-config": "4.0.0-alpha.3",
|
|
37
|
+
"@markuplint/ml-spec": "4.0.0-alpha.3",
|
|
38
|
+
"@markuplint/parser-utils": "4.0.0-alpha.3",
|
|
39
|
+
"@markuplint/selector": "4.0.0-alpha.3",
|
|
40
|
+
"@types/debug": "^4.1.9",
|
|
41
41
|
"debug": "^4.3.4",
|
|
42
42
|
"is-plain-object": "^5.0.0",
|
|
43
|
-
"tslib": "^2.6.
|
|
44
|
-
"type-fest": "^4.1
|
|
43
|
+
"tslib": "^2.6.2",
|
|
44
|
+
"type-fest": "^4.3.1"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "380836f7adc1ff7e8eaf9d869e68d29eee8f3b7e"
|
|
47
47
|
}
|