Bug Tracker

Opened 9 years ago

Closed 9 years ago

#8497 closed bug (cantfix)

jQuery.css and jQuery.cssHooks

Reported by: ex.devote@… Owned by:
Priority: undecided Milestone: 1.next
Component: css Version: 1.5.1
Keywords: Cc:
Blocked by: Blocking:

Description

jQuery 1.5.1 on line 5886 and line 5895


return val === "" | | val === "auto"? "0px": val;


Why did the return value is 0px instead of auto or emptiness?

var h = jQuery('<div style="height: auto;"></ div>').css('height');

variable h is equal to "0px" / / This is not right!

I have half the scripts because of this has stopped working :-(

Change History (6)

comment:1 Changed 9 years ago by Yomodo

As far as I know CSS does not require an unit indicator when a value is 0. Eg: border:0; is officially allowed instead of border:0px;

comment:2 Changed 9 years ago by devote

Current value of offsetHeight and offsetWidth is irrelavent to my concern.

in my css I have value "auto" but I'm getting "0px" in variable h

What's been set up as an "auto" should return as na "auto" I don't need it to be "0px" It's surely a bug (((

comment:3 Changed 9 years ago by devote

jQuery v1.4.2

alert(jQuery('<div style="height: auto;"></div>').css('height'));

result is showing "auto" Correct value :=)


jQuery v1.5.1

alert(jQuery('<div style="height: auto;"></div>').css('height'));

result is showing "0px" This is incorrect value, should be "auto"

comment:4 Changed 9 years ago by dmethvin

See also #7395

comment:5 in reply to:  4 Changed 9 years ago by devote <ex.devote@…>

Replying to dmethvin:

See also #7395

I do not understand is how can you specify a ticket for my ticket, I'm talking about function .css() and not about .width() and .height()

comment:6 Changed 9 years ago by john

Component: unfiledcss
Resolution: cantfix
Status: newclosed

The reason why we changed to returning a computed value is that it's consistent across all browsers -- it's impossible to reliably determine if a CSS property will return "auto" across all browsers. .css() returns the numerical, computed value.

Note: See TracTickets for help on using tickets.