@markuplint/ml-core 4.10.5 → 4.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [4.12.0](https://github.com/markuplint/markuplint/compare/@markuplint/ml-core@4.11.0...@markuplint/ml-core@4.12.0) (2025-02-04)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **ml-core:** fix to match pretended element type selectors ([3f6d139](https://github.com/markuplint/markuplint/commit/3f6d1395ca6aab3698bfde771e8ba7086acb83c7))
11
+
12
+ ### Features
13
+
14
+ - **ml-core:** add `matchMLSelector` method to Element ([cd822d6](https://github.com/markuplint/markuplint/commit/cd822d6f3f7b899ffbc03646337cb018d72ce5e7))
15
+
16
+ # [4.11.0](https://github.com/markuplint/markuplint/compare/@markuplint/ml-core@4.10.5...@markuplint/ml-core@4.11.0) (2024-12-04)
17
+
18
+ ### Features
19
+
20
+ - **ml-core:** add `caretPositionFromPoint` prop to MLDocument ([8f7e822](https://github.com/markuplint/markuplint/commit/8f7e822d29f6ec287b9470eae0f4630cc2627eb7))
21
+ - **ml-core:** add `currentCSSZoom` prop to MLElement ([8b12e07](https://github.com/markuplint/markuplint/commit/8b12e07481ee1bbe2d54c9b4179e06ed01250662))
22
+ - **ml-core:** add `fragmentDirective` prop to MLDocument ([a62b6b1](https://github.com/markuplint/markuplint/commit/a62b6b10612601fd49bcd35f23723f0466d1b988))
23
+ - **ml-core:** add `writingSuggestions` prop to MLElement ([59c1d66](https://github.com/markuplint/markuplint/commit/59c1d6682cff93a17d0da8da3cd3c4dd1c63482b))
24
+
6
25
  ## [4.10.5](https://github.com/markuplint/markuplint/compare/@markuplint/ml-core@4.10.4...@markuplint/ml-core@4.10.5) (2024-11-17)
7
26
 
8
27
  **Note:** Version bump only for package @markuplint/ml-core
package/lib/ml-core.d.ts CHANGED
@@ -10,7 +10,7 @@ export type MLCoreParams = {
10
10
  export declare class MLCore {
11
11
  #private;
12
12
  constructor({ parser, sourceCode, ruleset, rules, locale, schemas, parserOptions, severity, pretenders, filename, debug, configErrors, }: MLCoreParams);
13
- get document(): ParserError | Document<RuleConfigValue, PlainData>;
13
+ get document(): Document<RuleConfigValue, PlainData> | ParserError;
14
14
  setCode(sourceCode: string): void;
15
15
  update({ parser, ruleset, rules, locale, schemas, parserOptions, configErrors }: Partial<MLFabric>): void;
16
16
  verify(fix?: boolean): Promise<Violation[]>;
@@ -262,6 +262,13 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
262
262
  * @implements DOM API: `Document`
263
263
  */
264
264
  get forms(): HTMLCollectionOf<HTMLFormElement>;
265
+ /**
266
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
267
+ *
268
+ * @unsupported
269
+ * @implements DOM API: `Document`
270
+ */
271
+ get fragmentDirective(): FragmentDirective;
265
272
  /**
266
273
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
267
274
  *
@@ -1272,6 +1279,13 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
1272
1279
  * @implements DOM API: `Document`
1273
1280
  */
1274
1281
  captureEvents(): void;
1282
+ /**
1283
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
1284
+ *
1285
+ * @unsupported
1286
+ * @implements DOM API: `Document`
1287
+ */
1288
+ caretPositionFromPoint(x: number, y: number, options?: CaretPositionFromPointOptions): CaretPosition | null;
1275
1289
  /**
1276
1290
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
1277
1291
  *
@@ -1601,7 +1615,7 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
1601
1615
  * @unsupported
1602
1616
  * @implements DOM API: `Document`
1603
1617
  */
1604
- startViewTransition(callbackOptions?: UpdateCallback): ViewTransition;
1618
+ startViewTransition(callbackOptions?: ViewTransitionUpdateCallback): ViewTransition;
1605
1619
  /**
1606
1620
  * @implements `@markuplint/ml-core` API: `MLDocument`
1607
1621
  */
@@ -13,7 +13,7 @@ var _MLDocument_filename, _MLDocument_tokenList;
13
13
  import { exchangeValueOnRule, mergeRule } from '@markuplint/ml-config';
14
14
  import { schemaToSpec, getAccname, getComputedRole, mayBeFocusable, getComputedAriaProps, isExposed, ARIA_RECOMMENDED_VERSION, } from '@markuplint/ml-spec';
15
15
  import { ConfigParserError } from '@markuplint/parser-utils';
16
- import { InvalidSelectorError, matchSelector } from '@markuplint/selector';
16
+ import { InvalidSelectorError } from '@markuplint/selector';
17
17
  import { log as coreLog } from '../../debug.js';
18
18
  import { createNode } from '../helper/create-node.js';
19
19
  import { nodeListToDebugMaps } from '../helper/debug.js';
@@ -334,6 +334,15 @@ export class MLDocument extends MLParentNode {
334
334
  get forms() {
335
335
  throw new UnexpectedCallError('Not supported "forms" property');
336
336
  }
337
+ /**
338
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
339
+ *
340
+ * @unsupported
341
+ * @implements DOM API: `Document`
342
+ */
343
+ get fragmentDirective() {
344
+ throw new UnexpectedCallError('Not supported "fragmentDirective" property');
345
+ }
337
346
  /**
338
347
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
339
348
  *
@@ -1610,6 +1619,17 @@ export class MLDocument extends MLParentNode {
1610
1619
  captureEvents() {
1611
1620
  throw new UnexpectedCallError('Not supported "captureEvents" method');
1612
1621
  }
1622
+ /**
1623
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
1624
+ *
1625
+ * @unsupported
1626
+ * @implements DOM API: `Document`
1627
+ */
1628
+ caretPositionFromPoint(x, y,
1629
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
1630
+ options) {
1631
+ throw new UnexpectedCallError('Not supported "caretPositionFromPoint" method');
1632
+ }
1613
1633
  /**
1614
1634
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
1615
1635
  *
@@ -2239,7 +2259,7 @@ export class MLDocument extends MLParentNode {
2239
2259
  continue;
2240
2260
  }
2241
2261
  const selector = nodeRule.selector ?? nodeRule.regexSelector;
2242
- const matches = matchSelector(selectorTarget, selector);
2262
+ const matches = selectorTarget.matchMLSelector(selector);
2243
2263
  if (!matches.matched) {
2244
2264
  continue;
2245
2265
  }
@@ -2282,7 +2302,7 @@ export class MLDocument extends MLParentNode {
2282
2302
  if (selector == null) {
2283
2303
  continue;
2284
2304
  }
2285
- const matches = matchSelector(selectorTarget, selector);
2305
+ const matches = selectorTarget.matchMLSelector(selector);
2286
2306
  if (!matches.matched) {
2287
2307
  continue;
2288
2308
  }
@@ -4,8 +4,9 @@ import type { MLNode } from './node.js';
4
4
  import type { MLText } from './text.js';
5
5
  import type { ElementNodeType, PretenderContext } from './types.js';
6
6
  import type { ElementType, MLASTElement, NamespaceURI } from '@markuplint/ml-ast';
7
- import type { PlainData, Pretender, RuleConfigValue, RuleInfo } from '@markuplint/ml-config';
7
+ import type { PlainData, Pretender, RegexSelector, RuleConfigValue, RuleInfo } from '@markuplint/ml-config';
8
8
  import type { ARIAVersion } from '@markuplint/ml-spec';
9
+ import type { SelectorMatches } from '@markuplint/selector';
9
10
  import { MLToken } from '../token/token.js';
10
11
  import { MLAttr } from './attr.js';
11
12
  import { MLDomTokenList } from './dom-token-list.js';
@@ -466,6 +467,14 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
466
467
  * @implements DOM API: `Element`
467
468
  */
468
469
  get contentEditable(): string;
470
+ /**
471
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
472
+ *
473
+ * @deprecated
474
+ * @unsupported
475
+ * @implements DOM API: `Element`
476
+ */
477
+ get currentCSSZoom(): number;
469
478
  /**
470
479
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
471
480
  *
@@ -1573,6 +1582,14 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
1573
1582
  * @implements DOM API: `Element`
1574
1583
  */
1575
1584
  get translate(): boolean;
1585
+ /**
1586
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
1587
+ *
1588
+ * @deprecated
1589
+ * @unsupported
1590
+ * @implements DOM API: `Element`
1591
+ */
1592
+ get writingSuggestions(): string;
1576
1593
  /**
1577
1594
  * @implements DOM API: `Element`
1578
1595
  */
@@ -1841,6 +1858,7 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
1841
1858
  * @see https://dom.spec.whatwg.org/#ref-for-dom-element-matches%E2%91%A0
1842
1859
  */
1843
1860
  matches(selector: string, scope?: MLParentNode<T, O>): boolean;
1861
+ matchMLSelector(selector: string | RegexSelector | undefined, scope?: MLParentNode<T, O>): SelectorMatches;
1844
1862
  /**
1845
1863
  * Pretenders Initialization
1846
1864
  */
@@ -12,7 +12,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
12
12
  };
13
13
  var _MLElement_attributes, _MLElement_fixedNodeName, _MLElement_getChildElementsAndTextNodeWithoutWhitespacesCache, _MLElement_localName, _MLElement_normalizedAttrs, _MLElement_normalizedString;
14
14
  import { resolveNamespace } from '@markuplint/ml-spec';
15
- import { createSelector } from '@markuplint/selector';
15
+ import { matchSelector } from '@markuplint/selector';
16
16
  import { getAccname } from '../helper/accname.js';
17
17
  import { after, before, nextElementSibling, previousElementSibling, remove, replaceWith, } from '../manipulations/child-node-methods.js';
18
18
  import { MLToken } from '../token/token.js';
@@ -614,6 +614,16 @@ export class MLElement extends MLParentNode {
614
614
  get contentEditable() {
615
615
  throw new UnexpectedCallError('Not supported "contentEditable" property');
616
616
  }
617
+ /**
618
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
619
+ *
620
+ * @deprecated
621
+ * @unsupported
622
+ * @implements DOM API: `Element`
623
+ */
624
+ get currentCSSZoom() {
625
+ throw new UnexpectedCallError('Not supported "currentCSSZoom" property');
626
+ }
617
627
  /**
618
628
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
619
629
  *
@@ -2026,6 +2036,16 @@ export class MLElement extends MLParentNode {
2026
2036
  get translate() {
2027
2037
  throw new UnexpectedCallError('Not supported "translate" property');
2028
2038
  }
2039
+ /**
2040
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
2041
+ *
2042
+ * @deprecated
2043
+ * @unsupported
2044
+ * @implements DOM API: `Element`
2045
+ */
2046
+ get writingSuggestions() {
2047
+ throw new UnexpectedCallError('Not supported "writingSuggestions" property');
2048
+ }
2029
2049
  /**
2030
2050
  * @implements DOM API: `Element`
2031
2051
  */
@@ -2500,13 +2520,17 @@ export class MLElement extends MLParentNode {
2500
2520
  matches(selector,
2501
2521
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
2502
2522
  scope) {
2503
- let matched = false;
2504
- const selectorMatcher = createSelector(selector, this.ownerMLDocument.specs);
2523
+ return this.matchMLSelector(selector, scope).matched;
2524
+ }
2525
+ matchMLSelector(selector,
2526
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
2527
+ scope) {
2505
2528
  if (this.pretenderContext?.type === 'pretender') {
2506
- matched = selectorMatcher.match(this, scope) !== false;
2507
- }
2508
- if (matched) {
2509
- return true;
2529
+ // matched = selectorMatcher.match(this, scope) !== false;
2530
+ const matched = matchSelector(this, selector, scope, this.ownerMLDocument.specs);
2531
+ if (matched.matched) {
2532
+ return matched;
2533
+ }
2510
2534
  }
2511
2535
  let _pretender = null;
2512
2536
  // don't expose pretenders temporarily
@@ -2514,7 +2538,7 @@ export class MLElement extends MLParentNode {
2514
2538
  _pretender = this.pretenderContext;
2515
2539
  this.pretenderContext = null;
2516
2540
  }
2517
- matched = selectorMatcher.match(this, scope) !== false;
2541
+ const matched = matchSelector(this, selector, scope, this.ownerMLDocument.specs);
2518
2542
  if (_pretender) {
2519
2543
  this.pretenderContext = _pretender;
2520
2544
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/ml-core",
3
- "version": "4.10.5",
3
+ "version": "4.12.0",
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.5.10",
32
- "@markuplint/html-parser": "4.6.13",
33
- "@markuplint/html-spec": "4.11.0",
31
+ "@markuplint/config-presets": "4.5.11",
32
+ "@markuplint/html-parser": "4.6.15",
33
+ "@markuplint/html-spec": "4.12.0",
34
34
  "@markuplint/i18n": "4.6.0",
35
35
  "@markuplint/ml-ast": "4.4.9",
36
- "@markuplint/ml-config": "4.8.5",
37
- "@markuplint/ml-spec": "4.9.0",
38
- "@markuplint/parser-utils": "4.8.1",
39
- "@markuplint/selector": "4.6.13",
36
+ "@markuplint/ml-config": "4.8.7",
37
+ "@markuplint/ml-spec": "4.9.2",
38
+ "@markuplint/parser-utils": "4.8.3",
39
+ "@markuplint/selector": "4.7.0",
40
40
  "@markuplint/shared": "4.4.10",
41
41
  "@types/debug": "4.1.12",
42
- "debug": "4.3.7",
42
+ "debug": "4.4.0",
43
43
  "is-plain-object": "5.0.0",
44
- "type-fest": "4.27.0"
44
+ "type-fest": "4.33.0"
45
45
  },
46
- "gitHead": "b2154ecf1e67559a3791991752f45c9c0283801a"
46
+ "gitHead": "687a84e00546b8f1f2ed88125fe507239723c8d8"
47
47
  }