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

BUG with style={{display:undefined}} #853

Closed
devnixs opened this issue Sep 4, 2017 · 6 comments
Closed

BUG with style={{display:undefined}} #853

devnixs opened this issue Sep 4, 2017 · 6 comments

Comments

@mikewesthad
Copy link

Is this a bug because the same thing presumably works in React? Using this { display: this.state.visible ? '' : 'none' } would work in preact.

If it's something that needs to be fixed, I imagine updating this line to add a check if the style prop is undefined (and convert its value to an empty string) would do the trick.

@developit
Copy link
Member

Strange bug. It seems like node.style.display = undefined doesn't unset values? Interesting that using null works fine:

https://jsfiddle.net/9gnokkLj/1/

@developit
Copy link
Member

Confirmed, this is just a weird detail of how the style property works:
https://jsfiddle.net/szawjdhs/5/

@devnixs
Copy link
Author

devnixs commented Sep 5, 2017

Yep! But it should be fixed because the view should be a pure function of the state and props.
It's not the case here because it depends on what happened before.
Also, it works with React.

@developit
Copy link
Member

Agreed, definitely on the to-do list.

@marvinhagemeister
Copy link
Member

Good news: This issue is fixed in Preact X. I can't reproduce it anymore 🎉

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

No branches or pull requests

4 participants