Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#5583 closed bug (worksforme)

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:


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)

regexspacing.patch (1.7 KB) - added by Catrope 11 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 11 years ago by Catrope

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).

comment:2 Changed 11 years ago by Catrope

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 11 years ago by Catrope

Attachment: regexspacing.patch added


comment:3 Changed 11 years ago by dmethvin

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:


comment:4 Changed 11 years ago by Catrope

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.

comment:5 Changed 10 years ago by jitter

Component: unfiledcss
Priority: majorlow
Note: See TracTickets for help on using tickets.