Skip to main content

Bug Tracker

Side navigation

#4427 closed bug (fixed)

Opened March 26, 2009 08:09AM UTC

Closed March 14, 2011 10:16PM UTC

Last modified April 12, 2011 05:04AM UTC

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)
  • test.html (3.0 KB) - added by skyde March 26, 2009 08:16AM UTC.
Change History (7)

Changed August 07, 2009 04:54PM UTC by dmethvin comment:1

component: unfilledcore

Changed October 29, 2010 03:27PM UTC by rwaldron comment:2

component: corecss
milestone: 1.4
priority: minorundecided
status: newopen

Changed March 14, 2011 10:16PM UTC by danheberden comment:3

resolution: → fixed
status: openclosed

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

Changed April 12, 2011 04:17AM UTC by Azatoth comment:4

QUnit test for overriding important css declarations, references #4427

Changeset: 1299e89dcd803ee0ed48622c716dc3d4c8567cb7

Changed April 12, 2011 04:34AM UTC by timmywil comment:5

Azatoth: your pull was landed, but is causing fails in firefox 4 and opera 11.01.

Changed April 12, 2011 04:54AM UTC by jeresig comment:6

Revert "QUnit test for overriding important css declarations, references #4427"

This reverts commit 1299e89dcd803ee0ed48622c716dc3d4c8567cb7.

Conflicts:

test/unit/css.js

Changeset: 312df0441b16981dd697d74fcbc1e1f212b47b7e

Changed April 12, 2011 05:04AM UTC by danheberden comment:7