Skip to content

Commit 412f7e1

Browse files
web-padawanclaude
andauthored
refactor: drop the Polymer workaround from createComponent (#13056)
## Description Related to #13048 `createComponent` checked for a static `_properties` on the element class and, when present, handed `@lit/react` a mock class with the Polymer property map on its prototype. Every component in this monorepo is a Lit element, and no class under `packages/*/src` defines `_properties` anymore, so the branch was dead code carried over from vaadin/react-components. - Removed the `_properties` branch, the `PolymerConstructor` type and the `@ts-expect-error` from `packages/react-components/src/utils/createComponent.ts` - `elementClass` is typed as a plain constructor ## Type of change - Refactor 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
1 parent d93bed3 commit 412f7e1

1 file changed

Lines changed: 2 additions & 21 deletions

File tree

‎packages/react-components/src/utils/createComponent.ts‎

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ window.Vaadin.registrations.push({
3636
// TODO: Remove when types from @lit-labs/react are exported
3737
export type EventNames = Record<string, EventName | string>;
3838
type Constructor<T> = { new (): T; name: string };
39-
type PolymerConstructor<T> = Constructor<T> & { _properties: Record<string, unknown> };
4039
type Options<I extends HTMLElement, E extends EventNames = {}> = Readonly<{
4140
displayName?: string;
42-
elementClass: Constructor<I> | PolymerConstructor<I>;
41+
elementClass: Constructor<I>;
4342
events?: E;
4443
react: typeof window.React;
4544
tagName: string;
@@ -105,25 +104,7 @@ export function createComponent<I extends HTMLElement, E extends EventNames = {}
105104
): ReactWebComponent<I, E>;
106105

107106
export function createComponent<I extends HTMLElement, E extends EventNames = {}>(options: Options<I, E>): any {
108-
const { elementClass } = options;
109-
110-
return _createComponent(
111-
'_properties' in elementClass
112-
? {
113-
...options,
114-
// TODO: improve or remove the Polymer workaround
115-
// 'createComponent' relies on key presence on the custom element class,
116-
// but Polymer defines properties on the prototype when the first element
117-
// is created. Workaround: pass a mock object with properties in
118-
// the prototype.
119-
elementClass: {
120-
// @ts-expect-error: it is a specific workaround for Polymer classes.
121-
name: elementClass.name,
122-
prototype: { ...elementClass._properties, hidden: Boolean },
123-
},
124-
}
125-
: options,
126-
);
107+
return _createComponent(options);
127108
}
128109

129110
// A separate declaration is needed here for the same reason as `createComponent`.

0 commit comments

Comments
 (0)