-
Couldn't load subscription status.
- Fork 55
Description
Hi there π
After upgrading from v1.1.4 to v1.3.2, I noticed that my attributes were no longer shadowed by initializeAttrs(). I started digging and stumbled upon this piece of logic introduced in #191:
Line 39 in a8fb3ba
| if (initialized.has(instance)) return |
It prevents initializeAttrs() from doing anything the second time around, thus skipping the manual initialization of attributes. Also, it seems like this change was one of the main things addressed by the above-mentioned PR.
So, what would be the correct way now to initialize the attributes without the @attr decorator?
Thanks!
Example
<script>
class InfoMessage extends HTMLElement {
open = true
connectedCallback() {
initializeAttrs(this, ['open'])
}
}
controller(InfoMessage)
</script>
<info-message data-open="false"></info-message>controller(InfoMessage)wraps originalconnectedCallback()and calls:
Line 14 in a8fb3ba
| initializeAttrs(instance) |
InfoMessageis marked asinitialized(attrs.ts):
Line 40 in a8fb3ba
| initialized.add(instance) |
- The original
connectedCallback()is executed, butinitializeAttrs()would hit that early-return condition. this.openis stuck in its default state (true) π