Summary: | Unable to remove 'important' priority of a CSS shorthand property | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Xianzhu Wang <phnixwxz> | ||||
Component: | CSS | Assignee: | Nobody <webkit-unassigned> | ||||
Status: | RESOLVED CONFIGURATION CHANGED | ||||||
Severity: | Normal | CC: | ahmad.saleem792, ap, bfulgham, cdumez, ganna.khabibullina, ian, koivisto, menard, mitz, rniwa, simon.fraser, wangxianzhu | ||||
Priority: | P2 | ||||||
Version: | 528+ (Nightly build) | ||||||
Hardware: | PC | ||||||
OS: | OS X 10.5 | ||||||
See Also: | https://bugs.webkit.org/show_bug.cgi?id=162263 | ||||||
Attachments: |
|
Description
Xianzhu Wang
2010-11-05 01:29:19 PDT
Background is a shorthand property. Does this also affect regular properties? Just verified that the issue only affects shorthand properties. Maybe we can merge this bug into bug 49098 because they might be of the same cause? (In reply to comment #2) > Just verified that the issue only affects shorthand properties. Maybe we can merge this bug into bug 49098 because they might be of the same cause? It also affect regular longhand properties. It seems that it behaves like this on purpose : https://bugs.webkit.org/show_bug.cgi?id=60007 Now I couldn't find anything in the spec about Ian's comment : "An element with a !important property in its style will allow you to override this property in JavaScript without using !important." If I take the snippet and run it into Opera 11, Firefox 10 it runs as expecting overriding the !important property. So what should we do here? I'll be happy to make the patch if a behavior fix is needed. Ian, Dan??? (In reply to comment #3) > (In reply to comment #2) > > Just verified that the issue only affects shorthand properties. Maybe we can merge this bug into bug 49098 because they might be of the same cause? > > It also affect regular longhand properties. > > It seems that it behaves like this on purpose : > > https://bugs.webkit.org/show_bug.cgi?id=60007 > > Now I couldn't find anything in the spec about Ian's comment : > "An element with a !important property in its style will allow you to override this property in JavaScript without using !important." > > If I take the snippet and run it into Opera 11, Firefox 10 it runs as expecting overriding the !important property. > > So what should we do here? I'll be happy to make the patch if a behavior fix is needed. > > Ian, Dan??? If you have "#elem { background: yellow !important; background: red }" in a stylesheet, should the element end up yellow? If so, why should the behavior of the JS equivalent be different? (In reply to comment #4) > (In reply to comment #3) > > (In reply to comment #2) > > > Just verified that the issue only affects shorthand properties. Maybe we can merge this bug into bug 49098 because they might be of the same cause? > > > > It also affect regular longhand properties. > > > > It seems that it behaves like this on purpose : > > > > https://bugs.webkit.org/show_bug.cgi?id=60007 > > > > Now I couldn't find anything in the spec about Ian's comment : > > "An element with a !important property in its style will allow you to override this property in JavaScript without using !important." > > > > If I take the snippet and run it into Opera 11, Firefox 10 it runs as expecting overriding the !important property. > > > > So what should we do here? I'll be happy to make the patch if a behavior fix is needed. > > > > Ian, Dan??? > > If you have "#elem { background: yellow !important; background: red }" in a stylesheet, should the element end up yellow? If so, why should the behavior of the JS equivalent be different? The element should be yellow. Opera and Firefox are doing so. It then means that the behavior is different. I don't believe it's a bug, this seems to be xbrowser approach. Once set as important you cannot override the style with the other non-important style. Having met the same problem, I did the following: // Get the style object. var styleObj= document.getElementById('foo').style; // Remove the property with important priority you want to override. In the example below - height. styleObj.removeProperty('height'); // Set the new value for the property with non-important priority. document.getElementById('foo').style.setProperty('height', '100px', null); I am unable to reproduce this bug using attached test case in Safari 15.6 on macOS 12.6 and Safari show all three lines as red background and it is matched across all other browsers (Chrome Canary 106 and Firefox Nightly 104). Safari also pass quite a few tests on WPT while searching for (Important): https://wpt.fyi/results/css?label=master&label=experimental&aligned&q=important Just wanted to share updated results, ignore my comment, if I am incorrect here. Thanks! Yeah, this is working now. |