Skip to content

Commit 70a1d8e

Browse files
chore: refactor code to be compatible with es2022
PiperOrigin-RevId: 794698100
1 parent cd7512f commit 70a1d8e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

labs/behaviors/element-internals.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ export function mixinElementInternals<T extends MixinBase<LitElement>>(
6868
return this[privateInternals];
6969
}
7070

71-
[privateInternals]?: ElementInternals;
71+
// In preparation for ES2022, we need to declare this property to guard
72+
// against the base class calling [internals] in its constructor prematurely
73+
// setting this field. Without declare, once this field is defined, it would
74+
// initialize to undefined and `attachInternals()` could be called again.
75+
declare [privateInternals]?: ElementInternals;
7276
}
7377

7478
return WithElementInternalsElement;

0 commit comments

Comments
 (0)