You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While I was testing the attributes — trying to work my way around #207 — I found another subtle detail. Manually initialized attributes are never observed.
It doesn't expect the second argument (arguments aren't used either).
Now, internally defineObservedAttributes() pulls attribute names from getAttrNames(), which, in turn, pulls them from attrs (WeakMap). The only way to populate attrs is to use @attr decorator:
Maybe I'm missing something, but it seems like there's no way to specify observed attributes without decorators. In any case, it'd be very nice to clarify that 🙂
Thank you!
The text was updated successfully, but these errors were encountered:
Attributes are correctly initialized (solving #207) and being observed... This can actually be a recommended way to add attributes without decorators?.. A bit verbose, but no more than calling initializeAttrs() and defineObservedAttributes() manually. With a tiny wrapper on user's end it could look like defineAttrs(HelloWorldElement, ['foo']).
Hi folks,
While I was testing the attributes — trying to work my way around #207 — I found another subtle detail. Manually initialized attributes are never observed.
Catalyst's guide provides the following example for vanilla users: https://github.com/github/catalyst/blob/main/docs/_guide/attrs.md#what-about-without-decorators.
Please notice the second argument there
defineObservedAttributes(HelloWorldElement, ['foo'])
and compare it with the actual function declaration:catalyst/src/attr.ts
Line 99 in a8fb3ba
It doesn't expect the second argument (
arguments
aren't used either).Now, internally
defineObservedAttributes()
pulls attribute names fromgetAttrNames()
, which, in turn, pulls them fromattrs
(WeakMap
). The only way to populateattrs
is to use@attr
decorator:catalyst/src/attr.ts
Line 15 in a8fb3ba
Maybe I'm missing something, but it seems like there's no way to specify observed attributes without decorators. In any case, it'd be very nice to clarify that 🙂
Thank you!
The text was updated successfully, but these errors were encountered: