#2954 closed bug (fixed)
Use isNaN for IE opacity
Reported by: | lrbabe | Owned by: | flesler |
---|---|---|---|
Priority: | major | Milestone: | 1.3 |
Component: | css | Version: | 1.2.5 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
function attr of core.js (the second one) use a strange test to detect NaN :
parseInt( value ) + "" == "NaN" ?
If appropriate, replace it with :
isNaN(parseInt(value))?
See proposed patch.
Attachments (1)
Change History (9)
Changed 15 years ago by
Attachment: | patch_nan.txt added |
---|
comment:1 Changed 15 years ago by
Owner: | set to flesler |
---|---|
Status: | new → assigned |
I wanted to do the same change some weeks ago. But for some reason the results were different.
comment:2 Changed 15 years ago by
By the way, if we are just testing if the value is a number, shouldn't we use value.constructor == Number ?
comment:6 Changed 15 years ago by
Right. The change could probably fit. I don't see much gain but might make it in. Will check this asap, it requires a lot of testing.
comment:7 Changed 13 years ago by
Component: | core → css |
---|---|
Summary: | [patch] Use isNaN if appropriate → Use isNaN for IE opacity |
Here's the current line in 1.4.2:
var opacity = parseInt( value, 10 ) + "" === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")";
parseInt() only looks for valid leading digits that can be followed by non-digits, but isNaN() requires the entire string to be a valid number. Opacity should be a number from 0.0 to 1.0 (not an integer). Also the Microsoft docs say the opacity should be an integer from 0 to 100.
http://msdn.microsoft.com/en-us/library/ms532910%28v=VS.85%29.aspx
So it seems like the correct line would be this:
var opacity = isNaN(value) ? "" : "alpha(opacity=" + Math.round(value * 100) + ")";
comment:8 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Implemented in the rewrite of csshooks in 1.4.3.
patch to replace the test with isNaN()