Skip to content
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

Render initial undefined values #377

Merged
merged 2 commits into from
Jun 25, 2018

Conversation

bgotink
Copy link
Contributor

@bgotink bgotink commented Jun 24, 2018

As mentioned in #375, if all values for an AttributePart or PropertyPart are undefined, the initial render will not set the attribute/property. See this comment for an explanation as to why that's wrong.

Instead of adding an extra property to check for the initial render and introducing logic to update the property on the first render I simply added a check on the length of this._previousValue, as that array can only be empty for the initial render (the property is set to an empty array in the constructor; setValue always sets the property to a non-empty array).

expected '<div></div>' to equal '<div attribute="it\'s undefined"></div>'
For initial renders, _equalToPreviousValues must always return false. The other checks
will return true if all values in the part are undefined, meaning attributes can get
lost.

See lit#375
@justinfagnani justinfagnani merged commit 843dce3 into lit:master Jun 25, 2018
@justinfagnani
Copy link
Collaborator

Awesome fix, thanks!

neuronetio pushed a commit to neuronetio/lit-html that referenced this pull request Dec 2, 2019
Make `AttributePart#_equalToPreviousValues` always return false in the initial render

For initial renders, _equalToPreviousValues must always return false. The other checks
will return true if all values in the part are undefined, meaning attributes can get
lost.

See lit#375
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants