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
{{ message }}
Repository navigation
Attrs are never observed unless added with @attr decorator #208
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 🙂
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']).
Activity
kristoforsalmin commentedon Apr 29, 2022
Using
@attras a function (like in tests) is the best workaround I found so far: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()anddefineObservedAttributes()manually. With a tiny wrapper on user's end it could look likedefineAttrs(HelloWorldElement, ['foo']).Thoughts?