Side navigation
#2954 closed bug (fixed)
Opened May 29, 2008 01:37PM UTC
Closed October 03, 2010 12:51AM UTC
Last modified March 14, 2012 04:57PM UTC
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 (8)
Changed May 29, 2008 11:43PM UTC by comment:1
owner: | → flesler |
---|---|
status: | new → assigned |
Changed May 30, 2008 09:49AM UTC by comment:2
By the way, if we are just testing if the value is a number, shouldn't we use value.constructor == Number ?
Changed May 30, 2008 10:03AM UTC by comment:3
oops oops oops, never mind my last comment.
Changed May 30, 2008 10:09AM UTC by comment:4
... actually you can mind it.
Changed May 30, 2008 05:11PM UTC by comment:5
No, because it's a string.
So value.constructor == String.
Changed June 11, 2008 10:21PM UTC by comment:6
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.
Changed June 20, 2010 06:43PM UTC by comment:7
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) + ")";
Changed October 03, 2010 12:51AM UTC by comment:8
resolution: | → fixed |
---|---|
status: | assigned → closed |
Implemented in the rewrite of csshooks in 1.4.3.
I wanted to do the same change some weeks ago. But for some reason the results were different.