-
Notifications
You must be signed in to change notification settings - Fork 79
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
Handle numbers in styles
#46
Handle numbers in styles
#46
Conversation
Codecov Report
@@ Coverage Diff @@
## master #46 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 2 2
Lines 115 115
Branches 32 32
=====================================
Hits 115 115
Continue to review full report at Codecov.
|
@@ -55,7 +55,7 @@ function setElementProp(element, name, value, oldValue) { | |||
if (name === "key") { | |||
} else if (name === "style") { | |||
for (var name in merge(oldValue, (value = value || {}))) { | |||
element.style[name] = value[name] || "" | |||
element.style[name] = value[name] != null ? value[name] : "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With element.style[name]+=""
tests fail.
!= null
checks against null
and undefined
, so 0
is valid. Anything else will be already coerced into a string by the browser.
If I'm correct, this change will keep things intact and only allow 0
to be valid and not being swallowed as falsy. Everything else stays the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I wasn't thinking well! 😅
Thanks @acstll! 👍 |
You're welcome! |
This would solve #18
You can write
and get