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:
|
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 original connectedCallback() and calls:
|
initializeAttrs(instance) |
InfoMessage is marked as initialized (attrs.ts):
|
initialized.add(instance) |
- The original
connectedCallback() is executed, but initializeAttrs() would hit that early-return condition.
this.open is stuck in its default state (true) 😔
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:catalyst/src/attr.ts
Line 39 in a8fb3ba
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
@attrdecorator?Thanks!
Example
controller(InfoMessage)wraps originalconnectedCallback()and calls:catalyst/src/core.ts
Line 14 in a8fb3ba
InfoMessageis marked asinitialized(attrs.ts):catalyst/src/attr.ts
Line 40 in a8fb3ba
connectedCallback()is executed, butinitializeAttrs()would hit that early-return condition.this.openis stuck in its default state (true) 😔