Skip to content

Commit 9742b2b

Browse files
committed
refactor: align component check with ember-cli#2724 canonical (lists + scope)
Replace the inline PascalCase-regex isComponentInvocation heuristic with the lists + scope pattern established by @NullVoxPopuli in ember-cli#2689 and canonicalised by ember-cli#2724. The new lib/utils/is-native-element.js mirrors without conflict — whichever lands first introduces the file; the other rebases to a no-op on it. Heuristic approaches (PascalCase regex, `tag.includes('.')`, etc.) were explicitly rejected in ember-cli#2689 because lowercase tags CAN be components in GJS/GTS when the name is shadowed by a scope binding (`const div = MyComponent; <div />`). Scope analysis catches this; regex heuristics don't. Call site now uses `!isNativeElement(node, sourceCode)` directly to match the canonical usage pattern in ember-cli#2724's migrated rules.
1 parent ea10e14 commit 9742b2b

3 files changed

Lines changed: 7 additions & 97 deletions

File tree

lib/rules/template-no-noninteractive-tabindex.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { dom, roles } = require('aria-query');
2-
const { isComponentInvocation } = require('../utils/is-component-invocation');
2+
const { isNativeElement } = require('../utils/is-native-element');
33
const { isNativeInteractive } = require('../utils/native-interactive-elements');
44

55
// Interactive ARIA roles (widget/command/composite/input/range subtypes) —
@@ -100,18 +100,20 @@ module.exports = {
100100
},
101101

102102
create(context) {
103+
const sourceCode = context.sourceCode || context.getSourceCode();
103104
return {
104105
GlimmerElementNode(node) {
105106
const tabindex = findAttr(node, 'tabindex');
106107
if (!tabindex) {
107108
return;
108109
}
109110

110-
// Skip component invocations (PascalCase, named-arg, this-path,
111-
// dot-path, named-block). Fixes the <Article tabindex={{0}}> FP where
112-
// a PascalCase component name collided with a native tag after
111+
// Only native HTML / SVG / MathML elements are in scope. Authoritative
112+
// tag lists (html-tags + svg-tags + mathml-tag-names) plus scope-
113+
// shadowing detection. Fixes the <Article tabindex={{0}}> FP where a
114+
// PascalCase component name collided with a native tag after
113115
// lowercasing.
114-
if (isComponentInvocation(node)) {
116+
if (!isNativeElement(node, sourceCode)) {
115117
return;
116118
}
117119

lib/utils/is-component-invocation.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

tests/lib/utils/is-component-invocation-test.js

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)