@markuplint/ml-core 3.0.0-alpha.0 → 3.0.0-alpha.1
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 +49 -30
- package/lib/ml-dom/node/element.js +191 -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
|
*/
|
|
@@ -1670,6 +1685,10 @@ export declare class MLElement<T extends RuleConfigValue, O = null> extends MLPa
|
|
|
1670
1685
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-matches%E2%91%A0
|
|
1671
1686
|
*/
|
|
1672
1687
|
matches(selector: string): boolean;
|
|
1688
|
+
/**
|
|
1689
|
+
* Pretenders Initialization
|
|
1690
|
+
*/
|
|
1691
|
+
pretending(pretenders: Pretender[]): void;
|
|
1673
1692
|
/**
|
|
1674
1693
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1675
1694
|
*
|
|
@@ -1695,17 +1714,17 @@ export declare class MLElement<T extends RuleConfigValue, O = null> extends MLPa
|
|
|
1695
1714
|
*
|
|
1696
1715
|
* @unsupported
|
|
1697
1716
|
* @implements DOM API: `Element`
|
|
1698
|
-
* @see https://
|
|
1717
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-removeattributens%E2%91%A0
|
|
1699
1718
|
*/
|
|
1700
|
-
|
|
1719
|
+
removeAttributeNS(namespace: string | null, localName: string): void;
|
|
1701
1720
|
/**
|
|
1702
1721
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1703
1722
|
*
|
|
1704
1723
|
* @unsupported
|
|
1705
1724
|
* @implements DOM API: `Element`
|
|
1706
|
-
* @see https://
|
|
1725
|
+
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-D589198
|
|
1707
1726
|
*/
|
|
1708
|
-
|
|
1727
|
+
removeAttributeNode(attr: Attr): Attr;
|
|
1709
1728
|
/**
|
|
1710
1729
|
* @implements DOM API: `Element`
|
|
1711
1730
|
*/
|
|
@@ -1771,25 +1790,25 @@ export declare class MLElement<T extends RuleConfigValue, O = null> extends MLPa
|
|
|
1771
1790
|
*
|
|
1772
1791
|
* @unsupported
|
|
1773
1792
|
* @implements DOM API: `Element`
|
|
1774
|
-
* @see https://dom.spec.whatwg.org/#dom-element-
|
|
1793
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-setattributens%E2%91%A0
|
|
1775
1794
|
*/
|
|
1776
|
-
|
|
1795
|
+
setAttributeNS(namespace: string | null, qualifiedName: string, value: string): void;
|
|
1777
1796
|
/**
|
|
1778
1797
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1779
1798
|
*
|
|
1780
1799
|
* @unsupported
|
|
1781
1800
|
* @implements DOM API: `Element`
|
|
1782
|
-
* @see https://dom.spec.whatwg.org/#dom-element-
|
|
1801
|
+
* @see https://dom.spec.whatwg.org/#dom-element-setattributenode
|
|
1783
1802
|
*/
|
|
1784
|
-
|
|
1803
|
+
setAttributeNode(attr: Attr): Attr | null;
|
|
1785
1804
|
/**
|
|
1786
1805
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1787
1806
|
*
|
|
1788
1807
|
* @unsupported
|
|
1789
1808
|
* @implements DOM API: `Element`
|
|
1790
|
-
* @see https://dom.spec.whatwg.org/#
|
|
1809
|
+
* @see https://dom.spec.whatwg.org/#dom-element-setattributenodens
|
|
1791
1810
|
*/
|
|
1792
|
-
|
|
1811
|
+
setAttributeNodeNS(attr: Attr): Attr | null;
|
|
1793
1812
|
/**
|
|
1794
1813
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1795
1814
|
*
|
|
@@ -1798,14 +1817,6 @@ export declare class MLElement<T extends RuleConfigValue, O = null> extends MLPa
|
|
|
1798
1817
|
* @see https://www.w3.org/TR/pointerevents2/#idl-def-element-setpointercapture-pointerid
|
|
1799
1818
|
*/
|
|
1800
1819
|
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
1820
|
/**
|
|
1810
1821
|
* @implements `@markuplint/ml-core` API: `MLElement`
|
|
1811
1822
|
*/
|
|
@@ -1814,6 +1825,14 @@ export declare class MLElement<T extends RuleConfigValue, O = null> extends MLPa
|
|
|
1814
1825
|
* @implements `@markuplint/ml-core` API: `MLElement`
|
|
1815
1826
|
*/
|
|
1816
1827
|
toString(): string;
|
|
1828
|
+
/**
|
|
1829
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1830
|
+
*
|
|
1831
|
+
* @unsupported
|
|
1832
|
+
* @implements DOM API: `Element`
|
|
1833
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-toggleattribute%E2%91%A0
|
|
1834
|
+
*/
|
|
1835
|
+
toggleAttribute(qualifiedName: string, force?: boolean): boolean;
|
|
1817
1836
|
/**
|
|
1818
1837
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
1819
1838
|
*
|
|
@@ -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.**
|
|
@@ -2243,7 +2285,106 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2243
2285
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-matches%E2%91%A0
|
|
2244
2286
|
*/
|
|
2245
2287
|
matches(selector) {
|
|
2246
|
-
|
|
2288
|
+
var _a;
|
|
2289
|
+
return !!(0, selector_1.createSelector)(selector, this.ownerMLDocument.specs).match(
|
|
2290
|
+
// Prioritize the pretender
|
|
2291
|
+
((_a = this.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender' ? this.pretenderContext.as : this);
|
|
2292
|
+
}
|
|
2293
|
+
/**
|
|
2294
|
+
* Pretenders Initialization
|
|
2295
|
+
*/
|
|
2296
|
+
pretending(pretenders) {
|
|
2297
|
+
const pretenderConfig = pretenders === null || pretenders === void 0 ? void 0 : pretenders.find(option => this.matches(option.selector));
|
|
2298
|
+
if (!pretenderConfig) {
|
|
2299
|
+
return;
|
|
2300
|
+
}
|
|
2301
|
+
let nodeName;
|
|
2302
|
+
let namespace = 'html';
|
|
2303
|
+
const attributes = [];
|
|
2304
|
+
let aria;
|
|
2305
|
+
if (typeof pretenderConfig.as === 'string') {
|
|
2306
|
+
nodeName = pretenderConfig.as;
|
|
2307
|
+
}
|
|
2308
|
+
else {
|
|
2309
|
+
nodeName = pretenderConfig.as.element;
|
|
2310
|
+
namespace = pretenderConfig.as.namespace || namespace;
|
|
2311
|
+
if (pretenderConfig.as.inheritAttrs) {
|
|
2312
|
+
attributes.push(...this._astToken.attributes);
|
|
2313
|
+
}
|
|
2314
|
+
if (pretenderConfig.as.attrs) {
|
|
2315
|
+
attributes.push(...pretenderConfig.as.attrs.map(({ name, value }, i) => {
|
|
2316
|
+
const _value = value
|
|
2317
|
+
? typeof value === 'string'
|
|
2318
|
+
? value
|
|
2319
|
+
: this.getAttribute(value.fromAttr) || ''
|
|
2320
|
+
: '';
|
|
2321
|
+
return {
|
|
2322
|
+
...this._astToken,
|
|
2323
|
+
uuid: `${this.uuid}_attr_${i}`,
|
|
2324
|
+
type: 'html-attr',
|
|
2325
|
+
nodeName: name,
|
|
2326
|
+
spacesBeforeName: {
|
|
2327
|
+
...this._astToken,
|
|
2328
|
+
raw: '',
|
|
2329
|
+
},
|
|
2330
|
+
name: {
|
|
2331
|
+
...this._astToken,
|
|
2332
|
+
raw: name,
|
|
2333
|
+
},
|
|
2334
|
+
spacesBeforeEqual: {
|
|
2335
|
+
...this._astToken,
|
|
2336
|
+
raw: '',
|
|
2337
|
+
},
|
|
2338
|
+
equal: {
|
|
2339
|
+
...this._astToken,
|
|
2340
|
+
raw: '',
|
|
2341
|
+
},
|
|
2342
|
+
spacesAfterEqual: {
|
|
2343
|
+
...this._astToken,
|
|
2344
|
+
raw: '',
|
|
2345
|
+
},
|
|
2346
|
+
startQuote: {
|
|
2347
|
+
...this._astToken,
|
|
2348
|
+
raw: '',
|
|
2349
|
+
},
|
|
2350
|
+
value: {
|
|
2351
|
+
...this._astToken,
|
|
2352
|
+
raw: _value,
|
|
2353
|
+
},
|
|
2354
|
+
endQuote: {
|
|
2355
|
+
...this._astToken,
|
|
2356
|
+
raw: '',
|
|
2357
|
+
},
|
|
2358
|
+
isDuplicatable: true,
|
|
2359
|
+
parentNode: null,
|
|
2360
|
+
nextNode: null,
|
|
2361
|
+
prevNode: null,
|
|
2362
|
+
isFragment: false,
|
|
2363
|
+
isGhost: false,
|
|
2364
|
+
};
|
|
2365
|
+
}));
|
|
2366
|
+
}
|
|
2367
|
+
aria = pretenderConfig.as.aria;
|
|
2368
|
+
}
|
|
2369
|
+
const as = new MLElement({
|
|
2370
|
+
...this._astToken,
|
|
2371
|
+
uuid: this.uuid + '_pretender',
|
|
2372
|
+
raw: `<${nodeName}>`,
|
|
2373
|
+
nodeName,
|
|
2374
|
+
namespace,
|
|
2375
|
+
elementType: 'html',
|
|
2376
|
+
attributes,
|
|
2377
|
+
}, this.ownerMLDocument);
|
|
2378
|
+
as.resetChildren(this.childNodes);
|
|
2379
|
+
as.pretenderContext = {
|
|
2380
|
+
type: 'origin',
|
|
2381
|
+
origin: this,
|
|
2382
|
+
};
|
|
2383
|
+
this.pretenderContext = {
|
|
2384
|
+
type: 'pretender',
|
|
2385
|
+
as,
|
|
2386
|
+
aria,
|
|
2387
|
+
};
|
|
2247
2388
|
}
|
|
2248
2389
|
/**
|
|
2249
2390
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
@@ -2276,20 +2417,20 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2276
2417
|
*
|
|
2277
2418
|
* @unsupported
|
|
2278
2419
|
* @implements DOM API: `Element`
|
|
2279
|
-
* @see https://
|
|
2420
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-removeattributens%E2%91%A0
|
|
2280
2421
|
*/
|
|
2281
|
-
|
|
2282
|
-
throw new unexpected_call_error_1.default('Not supported "
|
|
2422
|
+
removeAttributeNS(namespace, localName) {
|
|
2423
|
+
throw new unexpected_call_error_1.default('Not supported "removeAttributeNS" method');
|
|
2283
2424
|
}
|
|
2284
2425
|
/**
|
|
2285
2426
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2286
2427
|
*
|
|
2287
2428
|
* @unsupported
|
|
2288
2429
|
* @implements DOM API: `Element`
|
|
2289
|
-
* @see https://
|
|
2430
|
+
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-D589198
|
|
2290
2431
|
*/
|
|
2291
|
-
|
|
2292
|
-
throw new unexpected_call_error_1.default('Not supported "
|
|
2432
|
+
removeAttributeNode(attr) {
|
|
2433
|
+
throw new unexpected_call_error_1.default('Not supported "removeAttributeNode" method');
|
|
2293
2434
|
}
|
|
2294
2435
|
/**
|
|
2295
2436
|
* @implements DOM API: `Element`
|
|
@@ -2372,30 +2513,30 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2372
2513
|
*
|
|
2373
2514
|
* @unsupported
|
|
2374
2515
|
* @implements DOM API: `Element`
|
|
2375
|
-
* @see https://dom.spec.whatwg.org/#dom-element-
|
|
2516
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-setattributens%E2%91%A0
|
|
2376
2517
|
*/
|
|
2377
|
-
|
|
2378
|
-
throw new unexpected_call_error_1.default('Not supported "
|
|
2518
|
+
setAttributeNS(namespace, qualifiedName, value) {
|
|
2519
|
+
throw new unexpected_call_error_1.default('Not supported "setAttributeNS" method');
|
|
2379
2520
|
}
|
|
2380
2521
|
/**
|
|
2381
2522
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2382
2523
|
*
|
|
2383
2524
|
* @unsupported
|
|
2384
2525
|
* @implements DOM API: `Element`
|
|
2385
|
-
* @see https://dom.spec.whatwg.org/#dom-element-
|
|
2526
|
+
* @see https://dom.spec.whatwg.org/#dom-element-setattributenode
|
|
2386
2527
|
*/
|
|
2387
|
-
|
|
2388
|
-
throw new unexpected_call_error_1.default('Not supported "
|
|
2528
|
+
setAttributeNode(attr) {
|
|
2529
|
+
throw new unexpected_call_error_1.default('Not supported "setAttributeNode" method');
|
|
2389
2530
|
}
|
|
2390
2531
|
/**
|
|
2391
2532
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2392
2533
|
*
|
|
2393
2534
|
* @unsupported
|
|
2394
2535
|
* @implements DOM API: `Element`
|
|
2395
|
-
* @see https://dom.spec.whatwg.org/#
|
|
2536
|
+
* @see https://dom.spec.whatwg.org/#dom-element-setattributenodens
|
|
2396
2537
|
*/
|
|
2397
|
-
|
|
2398
|
-
throw new unexpected_call_error_1.default('Not supported "
|
|
2538
|
+
setAttributeNodeNS(attr) {
|
|
2539
|
+
throw new unexpected_call_error_1.default('Not supported "setAttributeNodeNS" method');
|
|
2399
2540
|
}
|
|
2400
2541
|
/**
|
|
2401
2542
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
@@ -2407,16 +2548,6 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2407
2548
|
setPointerCapture(pointerId) {
|
|
2408
2549
|
throw new unexpected_call_error_1.default('Not supported "setPointerCapture" method');
|
|
2409
2550
|
}
|
|
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
2551
|
/**
|
|
2421
2552
|
* @implements `@markuplint/ml-core` API: `MLElement`
|
|
2422
2553
|
*/
|
|
@@ -2445,6 +2576,16 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2445
2576
|
toString() {
|
|
2446
2577
|
return this.raw;
|
|
2447
2578
|
}
|
|
2579
|
+
/**
|
|
2580
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2581
|
+
*
|
|
2582
|
+
* @unsupported
|
|
2583
|
+
* @implements DOM API: `Element`
|
|
2584
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-element-toggleattribute%E2%91%A0
|
|
2585
|
+
*/
|
|
2586
|
+
toggleAttribute(qualifiedName, force) {
|
|
2587
|
+
throw new unexpected_call_error_1.default('Not supported "toggleAttribute" method');
|
|
2588
|
+
}
|
|
2448
2589
|
/**
|
|
2449
2590
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
2450
2591
|
*
|
|
@@ -2457,4 +2598,4 @@ class MLElement extends parent_node_1.MLParentNode {
|
|
|
2457
2598
|
}
|
|
2458
2599
|
}
|
|
2459
2600
|
exports.MLElement = MLElement;
|
|
2460
|
-
_MLElement_attributes = new WeakMap(), _MLElement_fixedNodeName = new WeakMap(), _MLElement_getChildElementsAndTextNodeWithoutWhitespacesCache = new WeakMap(),
|
|
2601
|
+
_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
|