Bug Tracker

Modify

Ticket #8497 (closed bug: cantfix)

Opened 2 years ago

Last modified 2 years ago

jQuery.css and jQuery.cssHooks

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

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

comment:1 Changed 2 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 2 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 2 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 follow-up: ↓ 5 Changed 2 years ago by dmethvin

See also #7395

comment:5 in reply to: ↑ 4 Changed 2 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 2 years ago by john

  • Status changed from new to closed
  • Resolution set to cantfix
  • Component changed from unfiled to css

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.