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
I searched for an existing RRFC which might be relevant to my RRFC
Motivation
Currently the common pattern of setting default values for properties to do it in the constructor or class field instantiation. These are really more initial values that we lose after instantiation. Users may actually want some behavior where "unsetting" a property will revert to a default value.
It's possible to manually add this behavior by falling back to some value in render(), willUpdate(), or custom accessors[1] or even attribute converters if we wish to consider removing an attribute as "unsetting" as well.
There have also been calls for this behavior for or React wrapper[2] which we could add on at the wrapper level but would also be nice to have it for the underlying Lit element.
We do need to decide what "unsetting" means
Setting property to undefined
Setting property to null (probably not this?)
delete el[prop]; (unlikely to happen?)
Removing associated attribute
If we implement spread, encountering a missing property from a previously rendered spread.
How
Eventually when the only way to declare a property is with standard decorators, I believe we get access to the initial value set on the class field (with auto-accessor). Until then, we would need to add a property option for the default value.
Once we collect the default value, we can add it as a fallback value in an appropriate place like property setter or attribute converter.
Motivation
Currently the common pattern of setting default values for properties to do it in the constructor or class field instantiation. These are really more initial values that we lose after instantiation. Users may actually want some behavior where "unsetting" a property will revert to a default value.
It's possible to manually add this behavior by falling back to some value in
render()
,willUpdate()
, or custom accessors[1] or even attribute converters if we wish to consider removing an attribute as "unsetting" as well.There have also been calls for this behavior for or React wrapper[2] which we could add on at the wrapper level but would also be nice to have it for the underlying Lit element.
We do need to decide what "unsetting" means
undefined
null
(probably not this?)delete el[prop];
(unlikely to happen?)How
Eventually when the only way to declare a property is with standard decorators, I believe we get access to the initial value set on the class field (with auto-accessor). Until then, we would need to add a property option for the default value.
Once we collect the default value, we can add it as a fallback value in an appropriate place like property setter or attribute converter.
References
The text was updated successfully, but these errors were encountered: