-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting string property to undefined
, with reflect: true
, does not remove the attribute.
#872
Comments
I agree this is pretty inconsistent. I can't recall why this ended up this way, but removing the attribute when the property is set to null or undefined seems about right. I'm not sure how much we can change this at this point. If we could, do we have native reflected attributes we could look at. cc @sorvell |
At the very least, can't it make a string attribute empty for example? Now, the previous value is kept, which is about the worst behavior I can imagine in this particular use case. I'm saying that because you say |
if you prefix the attribute with . https://lit-html.polymer-project.org/guide/writing-templates removing attributes makes sense for checked, disable etc. or for custom boolean types eventually - not for strings. the lit-element docs
so seems to work in accordance with the docs. |
Fixed in Lit2... closing. |
Description
Setting string property to
undefined
, withreflect: true
, does not remove the attribute.EDIT: I see this is documented here... so my question is, why is this so inconsistent? For strings & numbers, undefined tells it not to change, but for booleans, objects, & arrays, undefined removes the attribute? It would make a lot more sense if undefined & null both removed the attribute for all cases.
Live Demo
https://stackblitz.com/edit/lit-element-example-ahub5j?file=index.html
Steps to Reproduce
my-element
withmood
set togood
via attributemy-element
to document.bodymood
toundefined
via propertymood
attribute is still setExpected Results
Expected mood attribute to be removed
Actual Results
Mood attribute is still set to
great
Browsers Affected
Versions
The text was updated successfully, but these errors were encountered: