- From: Joe Pea <notifications@github.com>
- Date: Thu, 26 Dec 2024 16:11:55 -0800
- To: WICG/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Friday, 27 December 2024 00:11:59 UTC
if it is not possible to modify the `attachInternals()` design, then a possibility is to introduce a new `getInternals()` method with the new behavior of throwing when called anywhere except in an element's constructor call stack. The best practice would be to stop using `attachInternals` and start using `getInternals`. Maybe eventually `attachInternals` could be deprecated. This is assuming that the engine can do something special wih `new SomeElement` to track the constructor call stack. If not, then another option could be that `getInternals` can only be called when an element is constructed without `new`, such as with `document.createElement()`. ```js const el = document.createElement('some-el') el.getInternals() // always a runtime error. ``` If you need the constructor, and don't have the name, then ```js const el = document.createElementFromClass(SomeClass) el.getInternals() // always a runtime error. ``` In either example, any `constructor` in the call stack can call `getInternals` without a runtime error. -- Reply to this email directly or view it on GitHub: https://github.com/WICG/webcomponents/issues/962#issuecomment-2563184484 You are receiving this because you are subscribed to this thread. Message ID: <WICG/webcomponents/issues/962/2563184484@github.com>
Received on Friday, 27 December 2024 00:11:59 UTC