Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#12083 closed bug (cantfix)

Chrome v20 Ignores Units When Setting Width

Reported by: anonymous Owned by: mikesherov
Priority: low Milestone: None
Component: css Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:

Description

Chrome v20.0.1132.57 m (good lord) ignores units when setting the width of a div.

Steps to repeat:

var scopeTest = jQuery('<div style="padding:0; border:0; width:10000em" </div>').appendTo($(document));
alert(scopeTest.css('width'));
alert(scopeTest.width());

In Chrome I get back "10000px" and "10000". In Firefox I get better values back: "160000px" and "160000" (assuming 10000em equals 160000px in the font). IE8 also returns the right numbers.

(jQuery 1.7.2 seems to return the right number and units for the first call -- "10000em" -- but still gets the second call wrong.)

Change History (4)

comment:1 Changed 11 years ago by Chris Rywalt <crywalt@…>

Sorry, I'm old. Here's a jsFiddle:

http://jsfiddle.net/jAVHY/

comment:2 Changed 11 years ago by mikesherov

Component: unfiledcss
Milestone: None1.9
Owner: set to mikesherov
Priority: undecidedlow
Status: newassigned

comment:3 Changed 11 years ago by mikesherov

Resolution: cantfix
Status: assignedclosed

This works as well as we can get it in 1.7.2 and 1.8b2.

Chrome v20 doesn't auto convert between ems and pixels. This can be intepreted as correct behavior according to the W3C specs... they don't really agree on whether pixels should always be returned when another absolute value ( like ems ). I'll open a ticket with Webkit to try to address this, but as you saw, we return the right values for .css('width'), use that.

Thanks for the report!

comment:4 Changed 11 years ago by dmethvin

Milestone: 1.9None
Note: See TracTickets for help on using tickets.