Skip to main content

Bug Tracker

Side navigation

#5583 closed bug (worksforme)

Opened December 02, 2009 04:14PM UTC

Closed December 03, 2009 01:16AM UTC

Last modified February 13, 2011 10:43PM UTC

Patch: .css() appends 'px' to all numeric values, IE barfs with "Invalid argument."

Reported by: Catrope Owned by:
Priority: low Milestone: 1.4.3
Component: css Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:
Description

When calling $('something').css('z-index', 10) , jQuery.prop() incorrectly transforms the 10 to '10px' . Firefox doesn't seem to mind, but IE throws a JS error.

jQuery.prop() does check for z-index and some other numeric non-pixel properties with !exclude.test(name) , but that doesn't help much with:

var exclude = / z - ? index | font - ? weight | opacity | zoom | line - ? height /i,

It sure does look nice with all those spaces, but it doesn't match any of the intended properties any more. The correct regex is:

var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,

This bug only happens when using jQuery in non-minified form, because the minifier (wrongly!) removes the spaces in the regex.

Attachments (1)
Change History (5)

Changed December 02, 2009 04:17PM UTC by Catrope comment:1

Correction: Firefox does mind, but instead of throwing errors, it only causes freeze-ups of form fields in side jQuery UI dialogs (which use z-index quite extensively).

Changed December 02, 2009 06:39PM UTC by Catrope comment:2

It turns out there's more of these abuses of regex spacing in the code:

isSimple = / ^ .[ ^ :# \\[\\.,]*$/;

if ( jQuery.isArray( value ) && / radio | checkbox / .test( this.type ) )

if ( name.match( / float /i ) ) // occurs twice

name = name.replace( / ( [A - Z] ) /g, "-$1" ).toLowerCase();

Changed December 03, 2009 01:16AM UTC by dmethvin comment:3

resolution: → worksforme
status: newclosed

I am not sure where you got that version of jQuery, but I don't see it in the original source or the Google apis version here:

http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js

Changed December 03, 2009 09:13AM UTC by Catrope comment:4

Never mind, I'm an idiot. We have a copy of jQuery in our SVN repo, and someone decided they'd run a JavaScript prettifier on it.

Changed February 13, 2011 10:43PM UTC by jitter comment:5

component: unfiledcss
milestone: 1.41.4.3
priority: majorlow
version: 1.3.21.4.2