#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: |
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 (6)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
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();
comment:3 Changed 13 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
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
comment:4 Changed 13 years ago by
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 12 years ago by
Component: | unfiled → css |
---|---|
Milestone: | 1.4 → 1.4.3 |
Priority: | major → low |
Version: | 1.3.2 → 1.4.2 |
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).