Support !important for styles?
Problem
We currently don't support `!important` as it has to be set using `style.setProperty(name, value, priority)`. This should be trivially easy to implement if it's something want to support, although I'm not sure about the performance implications (EDIT: #1886), although I can't imagine it would be measurable as we would be doing the string test ourselves and those are cheap. http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration ~~OK... apparently IE8 doesn't support this _at all_, it might still be worth implementing, for the future and for those who don't care about IE8.~~ ~~After further experimentation, apparently it is! `style.setAttribute(name, value)` (priority is part of the value).~~ But apparently that was wrong as well, the only way to set it seems to be with `cssText`, an acceptable work-around may be to just use `cssText` when we detect an `!important` style, which should be seldom enough that performance is a non-issue. An important consideration is that we _already_ support this for the initial render, but subsequent updates will _fail_ as `!important` isn't recognized for properties.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Support !important for styles?
Any word on the progress of this? I'm using react in a widget and a browser extension that work on third party sites and not being able to update !important styles is an issue for me
Trust Score
7 verifications
- 1
Any word on the progress of this? I'm using react in a widget and a browser exte
Any word on the progress of this? I'm using react in a widget and a browser extension that work on third party sites and not being able to update !important styles is an issue for me
Validation
Resolved in facebook/react GitHub issue #1881. Community reactions: 31 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep