#4427 closed bug (fixed)
jQuery.css(name) returns inconsistent results
Reported by: | skyde | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | |
Component: | css | Version: | 1.3.2 |
Keywords: | css | Cc: | |
Blocked by: | Blocking: |
Description
jQuery.css(name) returns inconsistent results depending on whether name is written camel-cased or hyphened, when !important style rules apply.
To repeat:
1) add a !important style rule to an element, for example background-color: #000 !important
2) change the property with jQuery, for example $(element).css('background-color', '#fff');
3) $(element).css('background-color') returns now #000, while $(element).css('backgroundColor') returns differently #fff
Firefox 3.0.7, Opera 9.52 and IE7 were tested to work this way, on webkit-based browsers (Safari 4 and Chrome 1 tested) $(element).css() overrides !important rules with both writing styles.
I don't know which one is the correct way (styles applied with $.css can be seen as inline styles, in which case they should be overridden by !important rules), but $.css should return consistent values in any case, not depending on writing style :)
See attachment for tests.
Attachments (1)
Change History (8)
Changed 14 years ago by
comment:1 Changed 14 years ago by
Component: | unfilled → core |
---|
comment:2 Changed 12 years ago by
Component: | core → css |
---|---|
Milestone: | 1.4 |
Priority: | minor → undecided |
Status: | new → open |
comment:3 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | open → closed |
I can't reproduce this:
http://jsfiddle.net/danheberden/NpAq4/3/
there seems to be no odd reporting for $.fn.css() using one or the other. Also, !important styles should remain as they are, well, important.
Checked in chrome 10, chromium 11, ff3, ff4, opera 11, safari 5, ie6-9rc1, and even on my iphone. All works as expected :D
comment:4 Changed 12 years ago by
QUnit test for overriding important css declarations, references #4427
Changeset: 1299e89dcd803ee0ed48622c716dc3d4c8567cb7
comment:5 Changed 12 years ago by
Azatoth: your pull was landed, but is causing fails in firefox 4 and opera 11.01.
comment:6 Changed 12 years ago by
Revert "QUnit test for overriding important css declarations, references #4427"
This reverts commit 1299e89dcd803ee0ed48622c716dc3d4c8567cb7.
Conflicts:
test/unit/css.js
Changeset: 312df0441b16981dd697d74fcbc1e1f212b47b7e
comment:7 Changed 12 years ago by
From the spec: http://www.w3.org/TR/DOM-Level-2-Style/css#CSS-DocumentCSS
Needs further review
http://jsfiddle.net/rwaldron/y8pku/1/