@markuplint/ml-core 3.0.0-alpha.0 → 3.0.0-alpha.2
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/ml-core.d.ts +1 -1
- package/lib/ml-core.js +12 -7
- package/lib/ml-dom/helper/accname.d.ts +2 -1
- package/lib/ml-dom/helper/accname.js +51 -2
- package/lib/ml-dom/helper/create-node.d.ts +2 -2
- package/lib/ml-dom/helper/create-node.js +1 -1
- package/lib/ml-dom/helper/debug.js +1 -1
- package/lib/ml-dom/helper/getIndent.d.ts +1 -1
- package/lib/ml-dom/node/attr.d.ts +5 -5
- package/lib/ml-dom/node/attr.js +9 -9
- package/lib/ml-dom/node/block.d.ts +1 -1
- package/lib/ml-dom/node/character-data.d.ts +2 -2
- package/lib/ml-dom/node/document-fragment.d.ts +2 -2
- package/lib/ml-dom/node/document-type.d.ts +1 -1
- package/lib/ml-dom/node/document.d.ts +28 -19
- package/lib/ml-dom/node/document.js +40 -17
- package/lib/ml-dom/node/dom-token-list.d.ts +2 -2
- package/lib/ml-dom/node/dom-token-list.js +6 -6
- package/lib/ml-dom/node/element.d.ts +53 -30
- package/lib/ml-dom/node/element.js +203 -50
- package/lib/ml-dom/node/node-list.d.ts +1 -1
- package/lib/ml-dom/node/node-store.d.ts +3 -3
- package/lib/ml-dom/node/node.d.ts +19 -12
- package/lib/ml-dom/node/node.js +35 -26
- package/lib/ml-dom/node/parent-node.d.ts +2 -2
- package/lib/ml-dom/node/types.d.ts +13 -3
- package/lib/ml-dom/token/token.d.ts +1 -1
- package/lib/ml-rule/ml-rule-context.d.ts +2 -1
- package/lib/ml-rule/ml-rule-context.js +19 -2
- package/lib/ml-rule/ml-rule.d.ts +4 -4
- package/lib/ml-rule/ml-rule.js +4 -4
- package/lib/ml-rule/types.d.ts +1 -1
- package/lib/test/index.d.ts +2 -1
- package/lib/test/index.js +5 -3
- package/lib/types.d.ts +3 -2
- package/package.json +11 -11
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/ml-dom/document.d.ts +0 -94
- package/lib/ml-dom/document.js +0 -273
- package/lib/ml-dom/helper/index.d.ts +0 -4
- package/lib/ml-dom/helper/index.js +0 -12
- package/lib/ml-dom/helper/mapped-nodes.d.ts +0 -52
- package/lib/ml-dom/helper/mapped-nodes.js +0 -2
- package/lib/ml-dom/helper/match-selector.d.ts +0 -20
- package/lib/ml-dom/helper/match-selector.js +0 -233
- package/lib/ml-dom/helper/node-store.d.ts +0 -12
- package/lib/ml-dom/helper/node-store.js +0 -28
- package/lib/ml-dom/helper/selector.d.ts +0 -11
- package/lib/ml-dom/helper/selector.js +0 -549
- package/lib/ml-dom/rule-mapper.d.ts +0 -16
- package/lib/ml-dom/rule-mapper.js +0 -57
- package/lib/ml-dom/tokens/abstract-element.d.ts +0 -54
- package/lib/ml-dom/tokens/abstract-element.js +0 -249
- package/lib/ml-dom/tokens/attribute.d.ts +0 -42
- package/lib/ml-dom/tokens/attribute.js +0 -85
- package/lib/ml-dom/tokens/comment.d.ts +0 -12
- package/lib/ml-dom/tokens/comment.js +0 -15
- package/lib/ml-dom/tokens/doctype.d.ts +0 -18
- package/lib/ml-dom/tokens/doctype.js +0 -32
- package/lib/ml-dom/tokens/element-close-tag.d.ts +0 -27
- package/lib/ml-dom/tokens/element-close-tag.js +0 -45
- package/lib/ml-dom/tokens/element.d.ts +0 -26
- package/lib/ml-dom/tokens/element.js +0 -66
- package/lib/ml-dom/tokens/index.d.ts +0 -10
- package/lib/ml-dom/tokens/index.js +0 -26
- package/lib/ml-dom/tokens/node.d.ts +0 -46
- package/lib/ml-dom/tokens/node.js +0 -126
- package/lib/ml-dom/tokens/omitted-element.d.ts +0 -13
- package/lib/ml-dom/tokens/omitted-element.js +0 -12
- package/lib/ml-dom/tokens/preprocessor-specific-attribute.d.ts +0 -24
- package/lib/ml-dom/tokens/preprocessor-specific-attribute.js +0 -37
- package/lib/ml-dom/tokens/preprocessor-specific-block.d.ts +0 -14
- package/lib/ml-dom/tokens/preprocessor-specific-block.js +0 -16
- package/lib/ml-dom/tokens/text.d.ts +0 -19
- package/lib/ml-dom/tokens/text.js +0 -26
- package/lib/ml-dom/tokens/token.d.ts +0 -16
- package/lib/ml-dom/tokens/token.js +0 -55
- package/lib/ml-dom/types.d.ts +0 -49
- package/lib/ml-dom/types.js +0 -2
- package/lib/selector/is-pure-html-element.d.ts +0 -1
- package/lib/selector/is-pure-html-element.js +0 -7
- package/lib/selector/match-selector.d.ts +0 -14
- package/lib/selector/match-selector.js +0 -230
- package/lib/selector/selector.d.ts +0 -9
- package/lib/selector/selector.js +0 -561
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { MLDocument } from './document';
|
|
2
2
|
import type { MLNamedNodeMap } from './named-node-map';
|
|
3
3
|
import type { MLText } from './text';
|
|
4
|
-
import type { ElementNodeType } from './types';
|
|
5
|
-
import type { MLASTElement, NamespaceURI } from '@markuplint/ml-ast';
|
|
6
|
-
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
4
|
+
import type { ElementNodeType, PretenderContext } from './types';
|
|
5
|
+
import type { ElementType, MLASTElement, NamespaceURI } from '@markuplint/ml-ast';
|
|
6
|
+
import type { Pretender, RuleConfigValue } from '@markuplint/ml-config';
|
|
7
|
+
import type { ARIAVersion } from '@markuplint/ml-spec';
|
|
7
8
|
import { MLToken } from '../token/token';
|
|
8
9
|
import { MLAttr } from './attr';
|
|
9
10
|
import { MLDomTokenList } from './dom-token-list';
|
|
@@ -11,9 +12,9 @@ import { MLParentNode } from './parent-node';
|
|
|
11
12
|
export declare class MLElement<T extends RuleConfigValue, O = null> extends MLParentNode<T, O, MLASTElement> implements Element, HTMLOrSVGElement, HTMLElement {
|
|
12
13
|
#private;
|
|
13
14
|
readonly closeTag: MLToken | null;
|
|
15
|
+
readonly elementType: ElementType;
|
|
14
16
|
readonly endSpace: MLToken | null;
|
|
15
17
|
readonly hasSpreadAttr: boolean;
|
|
16
|
-
readonly isCustomElement: boolean;
|
|
17
18
|
readonly isForeignElement: boolean;
|
|
18
19
|
readonly isOmitted: boolean;
|
|
19
20
|
readonly namespaceURI: NamespaceURI;
|
|
@@ -21,7 +22,9 @@ export declare class MLElement<T extends RuleConfigValue, O = null> extends MLPa
|
|
|
21
22
|
readonly ontouchend?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
|
|
22
23
|
readonly ontouchmove?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
|
|
23
24
|
readonly ontouchstart?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
|
|
25
|
+
pretenderContext: PretenderContext<MLElement<T, O>, T, O> | null;
|
|
24
26
|
readonly selfClosingSolidus: MLToken | null;
|
|
27
|
+
constructor(astNode: MLASTElement, document: MLDocument<T, O>);
|
|
25
28
|
/**
|
|
26
29
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
27
30
|
*
|
|
@@ -454,6 +457,15 @@ export declare class MLElement<T extends RuleConfigValue, O = null> extends MLPa
|
|
|
454
457
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-id%E2%91%A0
|
|
455
458
|
*/
|
|
456
459
|
get id(): string;
|
|
460
|
+
/**
|
|
461
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
462
|
+
*
|
|
463
|
+
* @deprecated
|
|
464
|
+
* @unsupported
|
|
465
|
+
* @implements DOM API: `Element`
|
|
466
|
+
* @see https://html.spec.whatwg.org/multipage/interaction.html#dom-inert
|
|
467
|
+
*/
|
|
468
|
+
get inert(): boolean;
|
|
457
469
|
/**
|
|
458
470
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
459
471
|
*
|
|
@@ -1444,7 +1456,6 @@ export declare class MLElement<T extends RuleConfigValue, O = null> extends MLPa
|
|
|
1444
1456
|
* @implements DOM API: `Element`
|
|
1445
1457
|
*/
|
|
1446
1458
|
get translate(): boolean;
|
|
1447
|
-
constructor(astNode: MLASTElement, document: MLDocument<T, O>);
|
|
1448
1459
|
/**
|
|
1449
1460
|
* @implements DOM API: `Element`
|
|
1450
1461
|
*/
|
|
@@ -1510,7 +1521,7 @@ export declare class MLElement<T extends RuleConfigValue, O = null> extends MLPa
|
|
|
1510
1521
|
/**
|
|
1511
1522
|
* @implements `@markuplint/ml-core` API: `MLElement`
|
|
1512
1523
|
*/
|
|
1513
|
-
getAccessibleName(): string;
|
|
1524
|
+
getAccessibleName(version: ARIAVersion): string;
|
|
1514
1525
|
/**
|
|
1515
1526
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1516
1527
|
*
|
|
@@ -1524,6 +1535,14 @@ export declare class MLElement<T extends RuleConfigValue, O = null> extends MLPa
|
|
|
1524
1535
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-getattribute%E2%91%A0
|
|
1525
1536
|
*/
|
|
1526
1537
|
getAttribute(attrName: string): string | null;
|
|
1538
|
+
/**
|
|
1539
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1540
|
+
*
|
|
1541
|
+
* @unsupported
|
|
1542
|
+
* @implements DOM API: `Element`
|
|
1543
|
+
* @see https://dom.spec.whatwg.org/#dom-element-getattributenodens
|
|
1544
|
+
*/
|
|
1545
|
+
getAttributeNS(namespace: string | null, localName: string): string | null;
|
|
1527
1546
|
/**
|
|
1528
1547
|
* @implements DOM API: `Element`
|
|
1529
1548
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-getattributenames%E2%91%A0
|
|
@@ -1543,13 +1562,9 @@ export declare class MLElement<T extends RuleConfigValue, O = null> extends MLPa
|
|
|
1543
1562
|
*/
|
|
1544
1563
|
getAttributeNodeNS(namespace: string | null, localName: string): Attr | null;
|
|
1545
1564
|
/**
|
|
1546
|
-
*
|
|
1547
|
-
*
|
|
1548
|
-
* @unsupported
|
|
1549
|
-
* @implements DOM API: `Element`
|
|
1550
|
-
* @see https://dom.spec.whatwg.org/#dom-element-getattributenodens
|
|
1565
|
+
* @implements `@markuplint/ml-core` API: `MLElement`
|
|
1551
1566
|
*/
|
|
1552
|
-
|
|
1567
|
+
getAttributePretended(attrName: string): string | null;
|
|
1553
1568
|
/**
|
|
1554
1569
|
* @implements `@markuplint/ml-core` API: `MLElement`
|
|
1555
1570
|
*/
|
|
@@ -1665,11 +1680,19 @@ export declare class MLElement<T extends RuleConfigValue, O = null> extends MLPa
|
|
|
1665
1680
|
* @implements `@markuplint/ml-core` API: `MLElement`
|
|
1666
1681
|
*/
|
|
1667
1682
|
isDescendantByUUIDList(uuidList: string[]): boolean;
|
|
1683
|
+
/**
|
|
1684
|
+
* @implements `@markuplint/ml-core` API: `MLElement`
|
|
1685
|
+
*/
|
|
1686
|
+
isEmpty(): boolean;
|
|
1668
1687
|
/**
|
|
1669
1688
|
* @implements DOM API: `Element`
|
|
1670
1689
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-matches%E2%91%A0
|
|
1671
1690
|
*/
|
|
1672
1691
|
matches(selector: string): boolean;
|
|
1692
|
+
/**
|
|
1693
|
+
* Pretenders Initialization
|
|
1694
|
+
*/
|
|
1695
|
+
pretending(pretenders: Pretender[]): void;
|
|
1673
1696
|
/**
|
|
1674
1697
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1675
1698
|
*
|
|
@@ -1695,17 +1718,17 @@ export declare class MLElement<T extends RuleConfigValue, O = null> extends MLPa
|
|
|
1695
1718
|
*
|
|
1696
1719
|
* @unsupported
|
|
1697
1720
|
* @implements DOM API: `Element`
|
|
1698
|
-
* @see https://
|
|
1721
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-removeattributens%E2%91%A0
|
|
1699
1722
|
*/
|
|
1700
|
-
|
|
1723
|
+
removeAttributeNS(namespace: string | null, localName: string): void;
|
|
1701
1724
|
/**
|
|
1702
1725
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1703
1726
|
*
|
|
1704
1727
|
* @unsupported
|
|
1705
1728
|
* @implements DOM API: `Element`
|
|
1706
|
-
* @see https://
|
|
1729
|
+
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-D589198
|
|
1707
1730
|
*/
|
|
1708
|
-
|
|
1731
|
+
removeAttributeNode(attr: Attr): Attr;
|
|
1709
1732
|
/**
|
|
1710
1733
|
* @implements DOM API: `Element`
|
|
1711
1734
|
*/
|
|
@@ -1771,25 +1794,25 @@ export declare class MLElement<T extends RuleConfigValue, O = null> extends MLPa
|
|
|
1771
1794
|
*
|
|
1772
1795
|
* @unsupported
|
|
1773
1796
|
* @implements DOM API: `Element`
|
|
1774
|
-
* @see https://dom.spec.whatwg.org/#dom-element-
|
|
1797
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-setattributens%E2%91%A0
|
|
1775
1798
|
*/
|
|
1776
|
-
|
|
1799
|
+
setAttributeNS(namespace: string | null, qualifiedName: string, value: string): void;
|
|
1777
1800
|
/**
|
|
1778
1801
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1779
1802
|
*
|
|
1780
1803
|
* @unsupported
|
|
1781
1804
|
* @implements DOM API: `Element`
|
|
1782
|
-
* @see https://dom.spec.whatwg.org/#dom-element-
|
|
1805
|
+
* @see https://dom.spec.whatwg.org/#dom-element-setattributenode
|
|
1783
1806
|
*/
|
|
1784
|
-
|
|
1807
|
+
setAttributeNode(attr: Attr): Attr | null;
|
|
1785
1808
|
/**
|
|
1786
1809
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1787
1810
|
*
|
|
1788
1811
|
* @unsupported
|
|
1789
1812
|
* @implements DOM API: `Element`
|
|
1790
|
-
* @see https://dom.spec.whatwg.org/#
|
|
1813
|
+
* @see https://dom.spec.whatwg.org/#dom-element-setattributenodens
|
|
1791
1814
|
*/
|
|
1792
|
-
|
|
1815
|
+
setAttributeNodeNS(attr: Attr): Attr | null;
|
|
1793
1816
|
/**
|
|
1794
1817
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1795
1818
|
*
|
|
@@ -1798,14 +1821,6 @@ export declare class MLElement<T extends RuleConfigValue, O = null> extends MLPa
|
|
|
1798
1821
|
* @see https://www.w3.org/TR/pointerevents2/#idl-def-element-setpointercapture-pointerid
|
|
1799
1822
|
*/
|
|
1800
1823
|
setPointerCapture(pointerId: number): void;
|
|
1801
|
-
/**
|
|
1802
|
-
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1803
|
-
*
|
|
1804
|
-
* @unsupported
|
|
1805
|
-
* @implements DOM API: `Element`
|
|
1806
|
-
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-toggleattribute%E2%91%A0
|
|
1807
|
-
*/
|
|
1808
|
-
toggleAttribute(qualifiedName: string, force?: boolean): boolean;
|
|
1809
1824
|
/**
|
|
1810
1825
|
* @implements `@markuplint/ml-core` API: `MLElement`
|
|
1811
1826
|
*/
|
|
@@ -1814,6 +1829,14 @@ export declare class MLElement<T extends RuleConfigValue, O = null> extends MLPa
|
|
|
1814
1829
|
* @implements `@markuplint/ml-core` API: `MLElement`
|
|
1815
1830
|
*/
|
|
1816
1831
|
toString(): string;
|
|
1832
|
+
/**
|
|
1833
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1834
|
+
*
|
|
1835
|
+
* @unsupported
|
|
1836
|
+
* @implements DOM API: `Element`
|
|
1837
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-toggleattribute%E2%91%A0
|
|
1838
|
+
*/
|
|
1839
|
+
toggleAttribute(qualifiedName: string, force?: boolean): boolean;
|
|
1817
1840
|
/**
|
|
1818
1841
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1819
1842
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _MLElement_attributes, _MLElement_fixedNodeName, _MLElement_getChildElementsAndTextNodeWithoutWhitespacesCache, _MLElement_normalizedAttrs, _MLElement_normalizedString,
|
|
2
|
+
var _MLElement_attributes, _MLElement_fixedNodeName, _MLElement_getChildElementsAndTextNodeWithoutWhitespacesCache, _MLElement_localName, _MLElement_normalizedAttrs, _MLElement_normalizedString, _MLElement_tagOpenChar;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.MLElement = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
@@ -22,9 +22,10 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
22
22
|
_MLElement_attributes.set(this, void 0);
|
|
23
23
|
_MLElement_fixedNodeName.set(this, void 0);
|
|
24
24
|
_MLElement_getChildElementsAndTextNodeWithoutWhitespacesCache.set(this, null);
|
|
25
|
-
_MLElement_normalizedAttrs.set(this, null);
|
|
26
|
-
_MLElement_normalizedString.set(this, null);
|
|
27
25
|
_MLElement_localName.set(this, void 0);
|
|
26
|
+
_MLElement_normalizedAttrs.set(this, new Map());
|
|
27
|
+
_MLElement_normalizedString.set(this, null);
|
|
28
|
+
this.pretenderContext = null;
|
|
28
29
|
_MLElement_tagOpenChar.set(this, void 0);
|
|
29
30
|
tslib_1.__classPrivateFieldSet(this, _MLElement_attributes, astNode.attributes.map(attr => new attr_1.MLAttr(attr, this)), "f");
|
|
30
31
|
this.hasSpreadAttr = astNode.hasSpreadAttr;
|
|
@@ -33,9 +34,9 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
33
34
|
this.closeTag = astNode.pearNode ? new token_1.MLToken(astNode.pearNode) : null;
|
|
34
35
|
const ns = (0, ml_spec_1.resolveNamespace)(astNode.nodeName, astNode.namespace);
|
|
35
36
|
this.namespaceURI = ns.namespaceURI;
|
|
37
|
+
this.elementType = astNode.elementType;
|
|
36
38
|
tslib_1.__classPrivateFieldSet(this, _MLElement_localName, ns.localName, "f");
|
|
37
39
|
this.isForeignElement = this.namespaceURI !== HTML_NAMESPACE;
|
|
38
|
-
this.isCustomElement = astNode.isCustomElement;
|
|
39
40
|
tslib_1.__classPrivateFieldSet(this, _MLElement_fixedNodeName, astNode.nodeName, "f");
|
|
40
41
|
this.isOmitted = astNode.isGhost;
|
|
41
42
|
tslib_1.__classPrivateFieldSet(this, _MLElement_tagOpenChar, astNode.tagOpenChar, "f");
|
|
@@ -435,12 +436,14 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
435
436
|
* @see https://dom.spec.whatwg.org/#dom-element-attributes
|
|
436
437
|
*/
|
|
437
438
|
get attributes() {
|
|
438
|
-
|
|
439
|
-
|
|
439
|
+
var _a;
|
|
440
|
+
const origin = ((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender' ? tslib_1.__classPrivateFieldGet(this.pretenderContext.as, _MLElement_attributes, "f") : tslib_1.__classPrivateFieldGet(this, _MLElement_attributes, "f");
|
|
441
|
+
if (tslib_1.__classPrivateFieldGet(this, _MLElement_normalizedAttrs, "f").has(origin)) {
|
|
442
|
+
return tslib_1.__classPrivateFieldGet(this, _MLElement_normalizedAttrs, "f").get(origin);
|
|
440
443
|
}
|
|
441
444
|
const names = new Set();
|
|
442
445
|
const attrs = [];
|
|
443
|
-
for (const attr of
|
|
446
|
+
for (const attr of origin) {
|
|
444
447
|
if (names.has(attr.name)) {
|
|
445
448
|
/**
|
|
446
449
|
* Skips a duplicated attribute
|
|
@@ -451,8 +454,9 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
451
454
|
}
|
|
452
455
|
attrs.push(attr);
|
|
453
456
|
}
|
|
454
|
-
|
|
455
|
-
|
|
457
|
+
const map = (0, named_node_map_1.toNamedNodeMap)(attrs);
|
|
458
|
+
tslib_1.__classPrivateFieldGet(this, _MLElement_normalizedAttrs, "f").set(origin, map);
|
|
459
|
+
return map;
|
|
456
460
|
}
|
|
457
461
|
/**
|
|
458
462
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
@@ -603,6 +607,17 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
603
607
|
get id() {
|
|
604
608
|
return this.getAttribute('id') || '';
|
|
605
609
|
}
|
|
610
|
+
/**
|
|
611
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
612
|
+
*
|
|
613
|
+
* @deprecated
|
|
614
|
+
* @unsupported
|
|
615
|
+
* @implements DOM API: `Element`
|
|
616
|
+
* @see https://html.spec.whatwg.org/multipage/interaction.html#dom-inert
|
|
617
|
+
*/
|
|
618
|
+
get inert() {
|
|
619
|
+
throw new unexpected_call_error_1.default('Not supported "inert" property');
|
|
620
|
+
}
|
|
606
621
|
/**
|
|
607
622
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
608
623
|
*
|
|
@@ -669,7 +684,11 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
669
684
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-localname%E2%91%A0
|
|
670
685
|
*/
|
|
671
686
|
get localName() {
|
|
672
|
-
|
|
687
|
+
var _a;
|
|
688
|
+
if (((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender') {
|
|
689
|
+
return this.pretenderContext.as.localName;
|
|
690
|
+
}
|
|
691
|
+
if (this.isForeignElement || this.elementType !== 'html') {
|
|
673
692
|
return tslib_1.__classPrivateFieldGet(this, _MLElement_localName, "f");
|
|
674
693
|
}
|
|
675
694
|
return tslib_1.__classPrivateFieldGet(this, _MLElement_localName, "f").toLowerCase();
|
|
@@ -690,7 +709,11 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
690
709
|
* @see https://dom.spec.whatwg.org/#ref-for-element%E2%91%A2%E2%93%AA
|
|
691
710
|
*/
|
|
692
711
|
get nodeName() {
|
|
693
|
-
|
|
712
|
+
var _a;
|
|
713
|
+
if (((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender') {
|
|
714
|
+
return this.pretenderContext.as.nodeName;
|
|
715
|
+
}
|
|
716
|
+
if (this.isForeignElement || this.elementType !== 'html') {
|
|
694
717
|
return this._astToken.nodeName;
|
|
695
718
|
}
|
|
696
719
|
return this._astToken.nodeName.toUpperCase();
|
|
@@ -1712,7 +1735,10 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
1712
1735
|
return (0, child_node_methods_1.previousElementSibling)(this);
|
|
1713
1736
|
}
|
|
1714
1737
|
get raw() {
|
|
1715
|
-
var _a;
|
|
1738
|
+
var _a, _b;
|
|
1739
|
+
if (((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender') {
|
|
1740
|
+
return this.originRaw;
|
|
1741
|
+
}
|
|
1716
1742
|
let fixed = this.originRaw;
|
|
1717
1743
|
let gap = 0;
|
|
1718
1744
|
if (this.nodeName !== this.fixedNodeName) {
|
|
@@ -1720,7 +1746,7 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
1720
1746
|
gap = gap + this.fixedNodeName.length - this.nodeName.length;
|
|
1721
1747
|
}
|
|
1722
1748
|
for (const attr of Array.from(this.attributes)) {
|
|
1723
|
-
const startOffset = (((
|
|
1749
|
+
const startOffset = (((_b = attr.spacesBeforeName) === null || _b === void 0 ? void 0 : _b.startOffset) || attr.startOffset) - this.startOffset;
|
|
1724
1750
|
const fixedAttr = attr.toString();
|
|
1725
1751
|
if (attr.originRaw !== fixedAttr) {
|
|
1726
1752
|
fixed = (0, string_splice_1.stringSplice)(fixed, startOffset + gap, attr.originRaw.length, fixedAttr);
|
|
@@ -1839,6 +1865,10 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
1839
1865
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-tagname%E2%91%A0
|
|
1840
1866
|
*/
|
|
1841
1867
|
get tagName() {
|
|
1868
|
+
var _a;
|
|
1869
|
+
if (((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender') {
|
|
1870
|
+
return this.pretenderContext.as.nodeName;
|
|
1871
|
+
}
|
|
1842
1872
|
return this.nodeName;
|
|
1843
1873
|
}
|
|
1844
1874
|
get textContent() {
|
|
@@ -1958,8 +1988,8 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
1958
1988
|
/**
|
|
1959
1989
|
* @implements `@markuplint/ml-core` API: `MLElement`
|
|
1960
1990
|
*/
|
|
1961
|
-
getAccessibleName() {
|
|
1962
|
-
return (0, accname_1.getAccname)(this);
|
|
1991
|
+
getAccessibleName(version) {
|
|
1992
|
+
return (0, accname_1.getAccname)(this, version);
|
|
1963
1993
|
}
|
|
1964
1994
|
/**
|
|
1965
1995
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
@@ -1983,6 +2013,16 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
1983
2013
|
}
|
|
1984
2014
|
return null;
|
|
1985
2015
|
}
|
|
2016
|
+
/**
|
|
2017
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2018
|
+
*
|
|
2019
|
+
* @unsupported
|
|
2020
|
+
* @implements DOM API: `Element`
|
|
2021
|
+
* @see https://dom.spec.whatwg.org/#dom-element-getattributenodens
|
|
2022
|
+
*/
|
|
2023
|
+
getAttributeNS(namespace, localName) {
|
|
2024
|
+
throw new unexpected_call_error_1.default('Not supported "getAttributeNS" method');
|
|
2025
|
+
}
|
|
1986
2026
|
/**
|
|
1987
2027
|
* @implements DOM API: `Element`
|
|
1988
2028
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-getattributenames%E2%91%A0
|
|
@@ -2008,14 +2048,15 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2008
2048
|
throw new unexpected_call_error_1.default('Not supported "getAttributeNodeNS" method');
|
|
2009
2049
|
}
|
|
2010
2050
|
/**
|
|
2011
|
-
*
|
|
2012
|
-
*
|
|
2013
|
-
* @unsupported
|
|
2014
|
-
* @implements DOM API: `Element`
|
|
2015
|
-
* @see https://dom.spec.whatwg.org/#dom-element-getattributenodens
|
|
2051
|
+
* @implements `@markuplint/ml-core` API: `MLElement`
|
|
2016
2052
|
*/
|
|
2017
|
-
|
|
2018
|
-
|
|
2053
|
+
getAttributePretended(attrName) {
|
|
2054
|
+
for (const attr of Array.from(tslib_1.__classPrivateFieldGet(this, _MLElement_attributes, "f"))) {
|
|
2055
|
+
if (attr.name.toLowerCase() === attrName.toLowerCase()) {
|
|
2056
|
+
return attr.value;
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
return null;
|
|
2019
2060
|
}
|
|
2020
2061
|
/**
|
|
2021
2062
|
* @implements `@markuplint/ml-core` API: `MLElement`
|
|
@@ -2034,7 +2075,8 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2034
2075
|
* @implements `@markuplint/ml-core` API: `MLElement`
|
|
2035
2076
|
*/
|
|
2036
2077
|
getAttributeTokens() {
|
|
2037
|
-
|
|
2078
|
+
var _a;
|
|
2079
|
+
return Object.freeze(((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender' ? tslib_1.__classPrivateFieldGet(this.pretenderContext.as, _MLElement_attributes, "f") : tslib_1.__classPrivateFieldGet(this, _MLElement_attributes, "f"));
|
|
2038
2080
|
}
|
|
2039
2081
|
/**
|
|
2040
2082
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
@@ -2238,12 +2280,123 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2238
2280
|
} while (el !== null && el.is(el.ELEMENT_NODE));
|
|
2239
2281
|
return false;
|
|
2240
2282
|
}
|
|
2283
|
+
/**
|
|
2284
|
+
* @implements `@markuplint/ml-core` API: `MLElement`
|
|
2285
|
+
*/
|
|
2286
|
+
isEmpty() {
|
|
2287
|
+
var _a;
|
|
2288
|
+
for (const childNode of Array.from(this.childNodes)) {
|
|
2289
|
+
if (!(childNode.is(childNode.TEXT_NODE) && ((_a = childNode.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === '')) {
|
|
2290
|
+
return false;
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
return true;
|
|
2294
|
+
}
|
|
2241
2295
|
/**
|
|
2242
2296
|
* @implements DOM API: `Element`
|
|
2243
2297
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-matches%E2%91%A0
|
|
2244
2298
|
*/
|
|
2245
2299
|
matches(selector) {
|
|
2246
|
-
|
|
2300
|
+
var _a;
|
|
2301
|
+
return !!(0, selector_1.createSelector)(selector, this.ownerMLDocument.specs).match(
|
|
2302
|
+
// Prioritize the pretender
|
|
2303
|
+
((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender' ? this.pretenderContext.as : this);
|
|
2304
|
+
}
|
|
2305
|
+
/**
|
|
2306
|
+
* Pretenders Initialization
|
|
2307
|
+
*/
|
|
2308
|
+
pretending(pretenders) {
|
|
2309
|
+
const pretenderConfig = pretenders === null || pretenders === void 0 ? void 0 : pretenders.find(option => this.matches(option.selector));
|
|
2310
|
+
if (!pretenderConfig) {
|
|
2311
|
+
return;
|
|
2312
|
+
}
|
|
2313
|
+
let nodeName;
|
|
2314
|
+
let namespace = 'html';
|
|
2315
|
+
const attributes = [];
|
|
2316
|
+
let aria;
|
|
2317
|
+
if (typeof pretenderConfig.as === 'string') {
|
|
2318
|
+
nodeName = pretenderConfig.as;
|
|
2319
|
+
}
|
|
2320
|
+
else {
|
|
2321
|
+
nodeName = pretenderConfig.as.element;
|
|
2322
|
+
namespace = pretenderConfig.as.namespace || namespace;
|
|
2323
|
+
if (pretenderConfig.as.inheritAttrs) {
|
|
2324
|
+
attributes.push(...this._astToken.attributes);
|
|
2325
|
+
}
|
|
2326
|
+
if (pretenderConfig.as.attrs) {
|
|
2327
|
+
attributes.push(...pretenderConfig.as.attrs.map(({ name, value }, i) => {
|
|
2328
|
+
const _value = value
|
|
2329
|
+
? typeof value === 'string'
|
|
2330
|
+
? value
|
|
2331
|
+
: this.getAttribute(value.fromAttr) || ''
|
|
2332
|
+
: '';
|
|
2333
|
+
return {
|
|
2334
|
+
...this._astToken,
|
|
2335
|
+
uuid: `${this.uuid}_attr_${i}`,
|
|
2336
|
+
type: 'html-attr',
|
|
2337
|
+
nodeName: name,
|
|
2338
|
+
spacesBeforeName: {
|
|
2339
|
+
...this._astToken,
|
|
2340
|
+
raw: '',
|
|
2341
|
+
},
|
|
2342
|
+
name: {
|
|
2343
|
+
...this._astToken,
|
|
2344
|
+
raw: name,
|
|
2345
|
+
},
|
|
2346
|
+
spacesBeforeEqual: {
|
|
2347
|
+
...this._astToken,
|
|
2348
|
+
raw: '',
|
|
2349
|
+
},
|
|
2350
|
+
equal: {
|
|
2351
|
+
...this._astToken,
|
|
2352
|
+
raw: '',
|
|
2353
|
+
},
|
|
2354
|
+
spacesAfterEqual: {
|
|
2355
|
+
...this._astToken,
|
|
2356
|
+
raw: '',
|
|
2357
|
+
},
|
|
2358
|
+
startQuote: {
|
|
2359
|
+
...this._astToken,
|
|
2360
|
+
raw: '',
|
|
2361
|
+
},
|
|
2362
|
+
value: {
|
|
2363
|
+
...this._astToken,
|
|
2364
|
+
raw: _value,
|
|
2365
|
+
},
|
|
2366
|
+
endQuote: {
|
|
2367
|
+
...this._astToken,
|
|
2368
|
+
raw: '',
|
|
2369
|
+
},
|
|
2370
|
+
isDuplicatable: true,
|
|
2371
|
+
parentNode: null,
|
|
2372
|
+
nextNode: null,
|
|
2373
|
+
prevNode: null,
|
|
2374
|
+
isFragment: false,
|
|
2375
|
+
isGhost: false,
|
|
2376
|
+
};
|
|
2377
|
+
}));
|
|
2378
|
+
}
|
|
2379
|
+
aria = pretenderConfig.as.aria;
|
|
2380
|
+
}
|
|
2381
|
+
const as = new MLElement({
|
|
2382
|
+
...this._astToken,
|
|
2383
|
+
uuid: this.uuid + '_pretender',
|
|
2384
|
+
raw: `<${nodeName}>`,
|
|
2385
|
+
nodeName,
|
|
2386
|
+
namespace,
|
|
2387
|
+
elementType: 'html',
|
|
2388
|
+
attributes,
|
|
2389
|
+
}, this.ownerMLDocument);
|
|
2390
|
+
as.resetChildren(this.childNodes);
|
|
2391
|
+
as.pretenderContext = {
|
|
2392
|
+
type: 'origin',
|
|
2393
|
+
origin: this,
|
|
2394
|
+
};
|
|
2395
|
+
this.pretenderContext = {
|
|
2396
|
+
type: 'pretender',
|
|
2397
|
+
as,
|
|
2398
|
+
aria,
|
|
2399
|
+
};
|
|
2247
2400
|
}
|
|
2248
2401
|
/**
|
|
2249
2402
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
@@ -2276,20 +2429,20 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2276
2429
|
*
|
|
2277
2430
|
* @unsupported
|
|
2278
2431
|
* @implements DOM API: `Element`
|
|
2279
|
-
* @see https://
|
|
2432
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-removeattributens%E2%91%A0
|
|
2280
2433
|
*/
|
|
2281
|
-
|
|
2282
|
-
throw new unexpected_call_error_1.default('Not supported "
|
|
2434
|
+
removeAttributeNS(namespace, localName) {
|
|
2435
|
+
throw new unexpected_call_error_1.default('Not supported "removeAttributeNS" method');
|
|
2283
2436
|
}
|
|
2284
2437
|
/**
|
|
2285
2438
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2286
2439
|
*
|
|
2287
2440
|
* @unsupported
|
|
2288
2441
|
* @implements DOM API: `Element`
|
|
2289
|
-
* @see https://
|
|
2442
|
+
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-D589198
|
|
2290
2443
|
*/
|
|
2291
|
-
|
|
2292
|
-
throw new unexpected_call_error_1.default('Not supported "
|
|
2444
|
+
removeAttributeNode(attr) {
|
|
2445
|
+
throw new unexpected_call_error_1.default('Not supported "removeAttributeNode" method');
|
|
2293
2446
|
}
|
|
2294
2447
|
/**
|
|
2295
2448
|
* @implements DOM API: `Element`
|
|
@@ -2372,30 +2525,30 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2372
2525
|
*
|
|
2373
2526
|
* @unsupported
|
|
2374
2527
|
* @implements DOM API: `Element`
|
|
2375
|
-
* @see https://dom.spec.whatwg.org/#dom-element-
|
|
2528
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-setattributens%E2%91%A0
|
|
2376
2529
|
*/
|
|
2377
|
-
|
|
2378
|
-
throw new unexpected_call_error_1.default('Not supported "
|
|
2530
|
+
setAttributeNS(namespace, qualifiedName, value) {
|
|
2531
|
+
throw new unexpected_call_error_1.default('Not supported "setAttributeNS" method');
|
|
2379
2532
|
}
|
|
2380
2533
|
/**
|
|
2381
2534
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2382
2535
|
*
|
|
2383
2536
|
* @unsupported
|
|
2384
2537
|
* @implements DOM API: `Element`
|
|
2385
|
-
* @see https://dom.spec.whatwg.org/#dom-element-
|
|
2538
|
+
* @see https://dom.spec.whatwg.org/#dom-element-setattributenode
|
|
2386
2539
|
*/
|
|
2387
|
-
|
|
2388
|
-
throw new unexpected_call_error_1.default('Not supported "
|
|
2540
|
+
setAttributeNode(attr) {
|
|
2541
|
+
throw new unexpected_call_error_1.default('Not supported "setAttributeNode" method');
|
|
2389
2542
|
}
|
|
2390
2543
|
/**
|
|
2391
2544
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2392
2545
|
*
|
|
2393
2546
|
* @unsupported
|
|
2394
2547
|
* @implements DOM API: `Element`
|
|
2395
|
-
* @see https://dom.spec.whatwg.org/#
|
|
2548
|
+
* @see https://dom.spec.whatwg.org/#dom-element-setattributenodens
|
|
2396
2549
|
*/
|
|
2397
|
-
|
|
2398
|
-
throw new unexpected_call_error_1.default('Not supported "
|
|
2550
|
+
setAttributeNodeNS(attr) {
|
|
2551
|
+
throw new unexpected_call_error_1.default('Not supported "setAttributeNodeNS" method');
|
|
2399
2552
|
}
|
|
2400
2553
|
/**
|
|
2401
2554
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
@@ -2407,16 +2560,6 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2407
2560
|
setPointerCapture(pointerId) {
|
|
2408
2561
|
throw new unexpected_call_error_1.default('Not supported "setPointerCapture" method');
|
|
2409
2562
|
}
|
|
2410
|
-
/**
|
|
2411
|
-
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2412
|
-
*
|
|
2413
|
-
* @unsupported
|
|
2414
|
-
* @implements DOM API: `Element`
|
|
2415
|
-
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-toggleattribute%E2%91%A0
|
|
2416
|
-
*/
|
|
2417
|
-
toggleAttribute(qualifiedName, force) {
|
|
2418
|
-
throw new unexpected_call_error_1.default('Not supported "toggleAttribute" method');
|
|
2419
|
-
}
|
|
2420
2563
|
/**
|
|
2421
2564
|
* @implements `@markuplint/ml-core` API: `MLElement`
|
|
2422
2565
|
*/
|
|
@@ -2445,6 +2588,16 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2445
2588
|
toString() {
|
|
2446
2589
|
return this.raw;
|
|
2447
2590
|
}
|
|
2591
|
+
/**
|
|
2592
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2593
|
+
*
|
|
2594
|
+
* @unsupported
|
|
2595
|
+
* @implements DOM API: `Element`
|
|
2596
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-toggleattribute%E2%91%A0
|
|
2597
|
+
*/
|
|
2598
|
+
toggleAttribute(qualifiedName, force) {
|
|
2599
|
+
throw new unexpected_call_error_1.default('Not supported "toggleAttribute" method');
|
|
2600
|
+
}
|
|
2448
2601
|
/**
|
|
2449
2602
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2450
2603
|
*
|
|
@@ -2457,4 +2610,4 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2457
2610
|
}
|
|
2458
2611
|
}
|
|
2459
2612
|
exports.MLElement = MLElement;
|
|
2460
|
-
_MLElement_attributes = new WeakMap(), _MLElement_fixedNodeName = new WeakMap(), _MLElement_getChildElementsAndTextNodeWithoutWhitespacesCache = new WeakMap(),
|
|
2613
|
+
_MLElement_attributes = new WeakMap(), _MLElement_fixedNodeName = new WeakMap(), _MLElement_getChildElementsAndTextNodeWithoutWhitespacesCache = new WeakMap(), _MLElement_localName = new WeakMap(), _MLElement_normalizedAttrs = new WeakMap(), _MLElement_normalizedString = new WeakMap(), _MLElement_tagOpenChar = new WeakMap();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MLChildNode } from './child-node';
|
|
2
2
|
import type { MLElement } from './element';
|
|
3
3
|
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
4
|
-
export declare function toNodeList<T extends RuleConfigValue, O
|
|
4
|
+
export declare function toNodeList<T extends RuleConfigValue, O, N extends MLChildNode<T, O>>(nodes: ReadonlyArray<N>): NodeListOf<N>;
|
|
5
5
|
export declare function toHTMLCollection<T extends RuleConfigValue, O = null>(nodes: ReadonlyArray<MLElement<T, O>>): HTMLCollectionOf<MLElement<T, O>>;
|
|
6
6
|
export declare function nodeListToHTMLCollection<T extends RuleConfigValue, O = null>(nodeList: NodeListOf<MLChildNode<T, O>>): HTMLCollectionOf<MLElement<T, O>>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { MLNode } from './node';
|
|
2
2
|
import type { MappedNode } from './types';
|
|
3
|
-
import type {
|
|
3
|
+
import type { MLASTAbstractNode } from '@markuplint/ml-ast';
|
|
4
4
|
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
5
5
|
declare class NodeStore {
|
|
6
6
|
#private;
|
|
7
|
-
getNode<N extends
|
|
8
|
-
setNode<A extends
|
|
7
|
+
getNode<N extends MLASTAbstractNode, T extends RuleConfigValue, O = null>(astNode: N): MappedNode<N, T, O>;
|
|
8
|
+
setNode<A extends MLASTAbstractNode, T extends RuleConfigValue, O = null>(astNode: A, node: MLNode<T, O, A>): void;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* `NodeStore` Singleton
|