Ticket #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: | ||
| Blocking: | Blocked by: |
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
comment:2 Changed 11 months ago by mikesherov
- Owner set to mikesherov
- Priority changed from undecided to low
- Status changed from new to assigned
- Component changed from unfiled to css
- Milestone changed from None to 1.9
comment:3 Changed 11 months ago by mikesherov
- Status changed from assigned to closed
- Resolution set to cantfix
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!
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Sorry, I'm old. Here's a jsFiddle:
http://jsfiddle.net/jAVHY/