@markuplint/rules 5.1.0 → 5.1.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,12 @@
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
+ ## [5.1.1](https://github.com/markuplint/markuplint/compare/v5.1.0...v5.1.1) (2026-10-09)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **rules:** check pretenders against content models that include #custom ([d70aa26](https://github.com/markuplint/markuplint/commit/d70aa2666c2318daaab4585aed62db00e5fd9a45))
11
+
6
12
  # [5.1.0](https://github.com/markuplint/markuplint/compare/v5.0.1...v5.1.0) (2026-10-08)
7
13
 
8
14
  ### Bug Fixes
@@ -109,7 +109,7 @@ childNode, specs, depth, mode) {
109
109
  };
110
110
  }
111
111
  if (childNode.is(childNode.ELEMENT_NODE)) {
112
- if (childNode.elementType !== 'html' && hasCustom) {
112
+ if (hasCustom && isTreatedAsCustom(childNode, mode)) {
113
113
  nodeLog('%s.matches(%s) => CustomElement', childNode.raw, query);
114
114
  return {
115
115
  type: 'MATCHED',
@@ -164,6 +164,34 @@ childNode, specs, depth, mode) {
164
164
  hint: {},
165
165
  };
166
166
  }
167
+ /**
168
+ * Whether an element is accepted by the `#custom` entry of a content model
169
+ * category without being checked against that category's tag list.
170
+ *
171
+ * `elementType` comes from the parser and does not change when the element is
172
+ * pretended, so a component that stands for `<section>` would still look
173
+ * authored and slip through `<p>`, `<span>` and `<button>`. In `'pretended'`
174
+ * mode such an element is judged by what it stands for instead, exactly as if
175
+ * the user had written that element. The pretender target is always created
176
+ * with `elementType: 'html'`, so a target that is itself a custom element
177
+ * (its name contains a hyphen) is recognised by name.
178
+ *
179
+ * In `'origin'` mode the pretender context is suppressed while matching (see
180
+ * {@link matches}) and the element is seen under its authored name, so it stays
181
+ * accepted as a custom element.
182
+ */
183
+ function isTreatedAsCustom(
184
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
185
+ element, mode) {
186
+ if (element.elementType === 'html') {
187
+ return false;
188
+ }
189
+ const pretenderContext = element.pretenderContext;
190
+ if (mode === 'pretended' && pretenderContext?.type === 'pretender') {
191
+ return pretenderContext.as.localName.includes('-');
192
+ }
193
+ return true;
194
+ }
167
195
  /**
168
196
  * Pre-computed conditions for well-known queries that do not depend on specs.
169
197
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/rules",
3
- "version": "5.1.0",
3
+ "version": "5.1.1",
4
4
  "description": "Built-in rules of markuplint",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,13 +31,13 @@
31
31
  "./lib/permitted-contents/debug.js": "./lib/permitted-contents/debug.browser.js"
32
32
  },
33
33
  "dependencies": {
34
- "@markuplint/html-spec": "5.1.0",
35
- "@markuplint/ml-config": "5.1.0",
36
- "@markuplint/ml-core": "5.1.0",
37
- "@markuplint/ml-spec": "5.1.0",
38
- "@markuplint/selector": "5.1.0",
39
- "@markuplint/shared": "5.1.0",
40
- "@markuplint/types": "5.1.0",
34
+ "@markuplint/html-spec": "5.1.1",
35
+ "@markuplint/ml-config": "5.1.1",
36
+ "@markuplint/ml-core": "5.1.1",
37
+ "@markuplint/ml-spec": "5.1.1",
38
+ "@markuplint/selector": "5.1.1",
39
+ "@markuplint/shared": "5.1.1",
40
+ "@markuplint/types": "5.1.1",
41
41
  "@mdn/browser-compat-data": "^7.3.2",
42
42
  "@types/debug": "4.1.13",
43
43
  "ansi-colors": "4.1.3",
@@ -47,5 +47,5 @@
47
47
  "image-size": "^2.0.2",
48
48
  "type-fest": "5.6.0"
49
49
  },
50
- "gitHead": "3a061784a8211034ad0c1cbd64798c0213414f65"
50
+ "gitHead": "a940c8526e971d590d97395ce924910221208820"
51
51
  }