Clear css properties when passed undefined#3862
Merged
Merged
Conversation
📊 Tachometer Benchmark ResultsSummaryduration
usedJSHeapSize
Results02_replace1k
duration
usedJSHeapSize
run-warmup-0
run-warmup-1
run-warmup-2
run-warmup-3
run-warmup-4
run-final
03_update10th1k_x16
duration
usedJSHeapSize
07_create10k
duration
usedJSHeapSize
filter_list
duration
usedJSHeapSize
hydrate1k
duration
usedJSHeapSize
many_updates
duration
usedJSHeapSize
text_update
duration
usedJSHeapSize
todo
duration
usedJSHeapSize
|
|
Size Change: +14 B (0%) Total Size: 52.9 kB
ℹ️ View Unchanged
|
Member
Author
|
P.S. Is this something we can file as a spec bug/change to HTML or CSS? Or is this one of the can of worms not worth opening 😅? |
JoviDeCroock
approved these changes
Jan 14, 2023
Member
Author
|
Gonna keep this in core since we already coerce undefined and null to empty string when setting style properties. This change makes our usage of setProperty aligned to what we do for style properties. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
style.setPropertyis givennullor'', the browser effectively clears the value (at least for css custom properties). However, when passedundefined, the browser serializesundefinedto the string"undefined"😢 . This PR modifies oursetStylefunction to handle undefined and convert it to an empty string in this case.Quick gut check: Is this something we want to support in core or put in compat? It's a fairly small change, but does fall into one of those changes where we are diverging from browser behavior so just wanted to check if that's something we want to put in core.
Fixes #3861