Bug Tracker

Opened 10 years ago

Closed 8 years ago

Last modified 8 years ago

#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)

test.html (3.0 KB) - added by skyde 10 years ago.

Download all attachments as: .zip

Change History (8)

Changed 10 years ago by skyde

Attachment: test.html added

comment:1 Changed 10 years ago by dmethvin

Component: unfilledcore

comment:2 Changed 8 years ago by Rick Waldron

Component: corecss
Milestone: 1.4
Priority: minorundecided
Status: newopen

comment:3 Changed 8 years ago by danheberden

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

comment:4 Changed 8 years ago by Azatoth

QUnit test for overriding important css declarations, references #4427

Changeset: 1299e89dcd803ee0ed48622c716dc3d4c8567cb7

comment:5 Changed 8 years ago by timmywil

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

comment:6 Changed 8 years ago by jeresig

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

This reverts commit 1299e89dcd803ee0ed48622c716dc3d4c8567cb7.

Conflicts:

test/unit/css.js

Changeset: 312df0441b16981dd697d74fcbc1e1f212b47b7e

Note: See TracTickets for help on using tickets.