Skip to content
This repository was archived by the owner on Aug 2, 2024. It is now read-only.

Commit e3a9f90

Browse files
committed
Add basic Glimmer component definition detection to is-component-definition
1 parent 83a1e79 commit e3a9f90

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

addon/helpers/is-component-definition.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,23 @@ export function isComponentDefinition(content) {
77
return false;
88
}
99

10+
// Glimmer now uses Symbol keys in its component definitions so we check those first.
11+
let symbolPropKeys = Object.getOwnPropertySymbols?.(content);
12+
if (symbolPropKeys?.length) {
13+
let isGlimmerComponentDefinition = symbolPropKeys.some((symbolPropKey) => {
14+
let propValue = content[symbolPropKey];
15+
return (
16+
propValue &&
17+
Object.keys(propValue).some((key) => key === 'ComponentClass')
18+
);
19+
});
20+
21+
if (isGlimmerComponentDefinition) {
22+
return true;
23+
}
24+
}
25+
1026
let contentPropNames = Object.keys(content);
11-
// This stopped working in Ember 3.17 when it was switched to use a Symbol instead
12-
// See https://github.com/glimmerjs/glimmer-vm/blob/master/CHANGELOG.md#v0450-2019-12-18 and
13-
// https://github.com/glimmerjs/glimmer-vm/pull/993 for more
1427
let isPreOctaneComponentDefinition = contentPropNames.some(
1528
(propName) => propName.indexOf('COMPONENT DEFINITION') > -1
1629
);

0 commit comments

Comments
 (0)