-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
fixed the issue that inline-styles updating could lose style properties #4661
Conversation
…es with new test cases
We won't take this as-is since setting all of the styles regardless of if they've changed will be bad for perf. It would probably be okay if we do this only in the case that the keys change, though it might be even better to do it only for shorthand properties (though I'm unsure if there's a way to do that without hardcoding them all). Maybe we could do something sneaky like looking for a prefix match. |
(Could've sworn we had an issue for this but I can't find it.) |
#2407 is the other issue. |
I was probably thinking of #2013. |
@spicyj Even only testing for shorthands seems unreasonably expensive, consider IMHO, all things considered it's better to just disallow overlapping and warn in dev. |
I agree with @syranide |
I'd say the cases that overwriting shorthand properties are quite common while styling. Rather than disable overlapping I personally think it's better to just disable the shorthand properties and only allow the non-shorthand to be set and precisely written in doc. |
background is shorthand for: background is NOT shorthand for backgroundSize. |
Yes it is. https://developer.mozilla.org/en-US/docs/Web/CSS/background#Formal_syntax |
Thank you for the correction. It looks like background IS shorthand for backgroundSize on newer browsers (IE 9+, Chrome 21+) but not on many browsers that are currently in use, including the mobile browser for which I am developing. That aside, the following:
Gets rendered as:
I am able to work around it by specifying each of the background properties individually.
I am not sure why the properties cannot be rendered as specified. This is leading to extra output that is unnecessary. |
@dheuermann It seems it behaves entirely as it should (it being part of |
@linmic updated the pull request. |
Sorry, I accidentally pushed a merge. Working on it. Please add the needs-revision tag back. |
Thank you for sending the PR! I’m closing it as it hasn’t been updated in a few months, and it seems to me from this and other discussions that the consensus is that we should warn on mixing shorthand with normal properties. I opened #6348 so we can all agree on the implementation strategy that wouldn’t compromise performance, and discuss what we learned from other libraries like Radium and React Native, before diving into a specific implementation. I’m sorry this pull request didn’t get through but I hope to hear your thoughts in the discussion in #6348. Cheers! |
I've encountered an issue that when I tried to update the inline styles of a node, it could lose some of the style properties which may lead to unintentional layout broke.
Say I want to replace an inline-style:
with
on an onChange event. And the properties won't be completely replaced/copied during the process.