@markuplint/ml-core 4.11.0 → 4.12.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/CHANGELOG.md CHANGED
@@ -3,6 +3,20 @@
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.1](https://github.com/markuplint/markuplint/compare/@markuplint/ml-core@4.12.0...@markuplint/ml-core@4.12.1) (2025-02-11)
7
+
8
+ **Note:** Version bump only for package @markuplint/ml-core
9
+
10
+ # [4.12.0](https://github.com/markuplint/markuplint/compare/@markuplint/ml-core@4.11.0...@markuplint/ml-core@4.12.0) (2025-02-04)
11
+
12
+ ### Bug Fixes
13
+
14
+ - **ml-core:** fix to match pretended element type selectors ([3f6d139](https://github.com/markuplint/markuplint/commit/3f6d1395ca6aab3698bfde771e8ba7086acb83c7))
15
+
16
+ ### Features
17
+
18
+ - **ml-core:** add `matchMLSelector` method to Element ([cd822d6](https://github.com/markuplint/markuplint/commit/cd822d6f3f7b899ffbc03646337cb018d72ce5e7))
19
+
6
20
  # [4.11.0](https://github.com/markuplint/markuplint/compare/@markuplint/ml-core@4.10.5...@markuplint/ml-core@4.11.0) (2024-12-04)
7
21
 
8
22
  ### Features
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(): Document<RuleConfigValue, PlainData> | ParserError;
13
+ get document(): ParserError | Document<RuleConfigValue, PlainData>;
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[]>;
@@ -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';
@@ -2259,7 +2259,7 @@ export class MLDocument extends MLParentNode {
2259
2259
  continue;
2260
2260
  }
2261
2261
  const selector = nodeRule.selector ?? nodeRule.regexSelector;
2262
- const matches = matchSelector(selectorTarget, selector);
2262
+ const matches = selectorTarget.matchMLSelector(selector);
2263
2263
  if (!matches.matched) {
2264
2264
  continue;
2265
2265
  }
@@ -2302,7 +2302,7 @@ export class MLDocument extends MLParentNode {
2302
2302
  if (selector == null) {
2303
2303
  continue;
2304
2304
  }
2305
- const matches = matchSelector(selectorTarget, selector);
2305
+ const matches = selectorTarget.matchMLSelector(selector);
2306
2306
  if (!matches.matched) {
2307
2307
  continue;
2308
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';
@@ -1857,6 +1858,7 @@ export declare class MLElement<T extends RuleConfigValue, O extends PlainData =
1857
1858
  * @see https://dom.spec.whatwg.org/#ref-for-dom-element-matches%E2%91%A0
1858
1859
  */
1859
1860
  matches(selector: string, scope?: MLParentNode<T, O>): boolean;
1861
+ matchMLSelector(selector: string | RegexSelector | undefined, scope?: MLParentNode<T, O>): SelectorMatches;
1860
1862
  /**
1861
1863
  * Pretenders Initialization
1862
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';
@@ -2520,13 +2520,17 @@ export class MLElement extends MLParentNode {
2520
2520
  matches(selector,
2521
2521
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
2522
2522
  scope) {
2523
- let matched = false;
2524
- 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) {
2525
2528
  if (this.pretenderContext?.type === 'pretender') {
2526
- matched = selectorMatcher.match(this, scope) !== false;
2527
- }
2528
- if (matched) {
2529
- 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
+ }
2530
2534
  }
2531
2535
  let _pretender = null;
2532
2536
  // don't expose pretenders temporarily
@@ -2534,7 +2538,7 @@ export class MLElement extends MLParentNode {
2534
2538
  _pretender = this.pretenderContext;
2535
2539
  this.pretenderContext = null;
2536
2540
  }
2537
- matched = selectorMatcher.match(this, scope) !== false;
2541
+ const matched = matchSelector(this, selector, scope, this.ownerMLDocument.specs);
2538
2542
  if (_pretender) {
2539
2543
  this.pretenderContext = _pretender;
2540
2544
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/ml-core",
3
- "version": "4.11.0",
3
+ "version": "4.12.1",
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.14",
33
- "@markuplint/html-spec": "4.11.1",
31
+ "@markuplint/config-presets": "4.5.12",
32
+ "@markuplint/html-parser": "4.6.16",
33
+ "@markuplint/html-spec": "4.13.0",
34
34
  "@markuplint/i18n": "4.6.0",
35
35
  "@markuplint/ml-ast": "4.4.9",
36
- "@markuplint/ml-config": "4.8.6",
37
- "@markuplint/ml-spec": "4.9.1",
38
- "@markuplint/parser-utils": "4.8.2",
39
- "@markuplint/selector": "4.6.14",
36
+ "@markuplint/ml-config": "4.8.8",
37
+ "@markuplint/ml-spec": "4.9.3",
38
+ "@markuplint/parser-utils": "4.8.4",
39
+ "@markuplint/selector": "4.7.1",
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.30.0"
44
+ "type-fest": "4.34.1"
45
45
  },
46
- "gitHead": "2a067903214e5633bd9b77690613837ead9683c3"
46
+ "gitHead": "f9f6c415b8a3a231aac56181892bb393aeb8ae1a"
47
47
  }