WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
73941
Handling of !important in inline style sets is broken
https://bugs.webkit.org/show_bug.cgi?id=73941
Summary
Handling of !important in inline style sets is broken
Boris Zbarsky
Reported
2011-12-06 11:49:31 PST
Consider the attached testcase, which does: document.getElementById("x").style.color = "red !important"; Per
http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface
the behavior should be: Similarly for the table below, setting the IDL attribute in the first column must invoke setProperty() with as first argument the CSS property given in the second column on the same row, as second argument the given value, and no third argument. and the definition of setProperty says: If parsing the value returns null terminate this algorithm. Note: value can not include "!important". WebKit gets the setProperty part right, but not the idl attribute set part. Gecko and IE9 get the idl attribute part right.
Attachments
Testcase
(167 bytes, text/html)
2011-12-06 11:50 PST
,
Boris Zbarsky
no flags
Details
proposed fix
(19.16 KB, patch)
2011-12-07 11:43 PST
,
Alexey Proskuryakov
hyatt
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Boris Zbarsky
Comment 1
2011-12-06 11:50:10 PST
Created
attachment 118083
[details]
Testcase
Boris Zbarsky
Comment 2
2011-12-06 11:53:30 PST
Not only that, but if I put a space after the '!' suddenly the color ends up green. Which is just completely weird, since in CSS syntax a space is allowed after '!', so it's not like this is an accidental behavior due to using the normal CSS parser...
Alexey Proskuryakov
Comment 3
2011-12-07 10:44:38 PST
This behavior is a result of a fix in
bug 8223
. The claim there was that both IE and Firefox supported "!important" when setting property values via IDL attributes. What that always untrue, or did the behavior change since 2006?
> Not only that, but if I put a space after the '!' suddenly the color ends up green.
Yes, the fix for
bug 8223
failed to take this into account.
Alexey Proskuryakov
Comment 4
2011-12-07 11:43:14 PST
Created
attachment 118242
[details]
proposed fix I'm still puzzled why other browsers apparently turned around on this, but even in the absence of an explanation, if seems like we should do the same.
Dave Hyatt
Comment 5
2011-12-07 11:46:19 PST
Comment on
attachment 118242
[details]
proposed fix r=me
Alexey Proskuryakov
Comment 6
2011-12-07 11:54:18 PST
Committed <
http://trac.webkit.org/changeset/102262
>.
Boris Zbarsky
Comment 7
2011-12-07 11:59:16 PST
Ah, interesting. IE9 is weird. On the testcase in this bug (even if I add a <body> to make their old parser happy), it ignores the style set in all modes. On the testcase in
bug 8223
, it sets the style in quirks, IE7, and IE8 modes, but not in IE9 standards mode. Do you see that too? As for Gecko, it accepted all sorts of gunk in inline style until Gecko 1.9 as long as it started with a valid value followed by '!' or ';' (for example, style.color = "red; flowery petals" would have parsed, as would have "red! for it is so pretty"). This was fixed in
https://bugzilla.mozilla.org/show_bug.cgi?id=383075
Thanks for the quick fix!
Alexey Proskuryakov
Comment 8
2011-12-07 13:36:15 PST
Thanks for the info. I didn't test IE very closely, just checked that your test passed. We'll see if this change breaks any content.
Csaba Osztrogonác
Comment 9
2011-12-07 23:34:26 PST
And an unreviewed buildfix landed in
http://trac.webkit.org/changeset/102318
... :(
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug