-
Notifications
You must be signed in to change notification settings - Fork 20.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First attempt at fixing #7912: $.fx.prototype.cur() is incompatible with cssHooks #165
Conversation
…t('jQuery.fx.prototype.cur')
// Empty strings and "auto" are converted to 0, | ||
// complex values such as "rotate(1rad)" are returned as is, | ||
// simple values such as "10px" are parsed to Float. | ||
return r === "" || r === "auto"? 0 : isNaN( parsed = parseFloat(r) )? r : parsed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using $.isNaN here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$.isNaN mostly handles the case of isNaN("")==false which doesn't apply here since parseFloat("") returns NaN and the "" case is checked earlier anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jQuery.isNaN() is only faster for values != NaN, and parsFloat returns exactly NaN when it fails.
// Empty strings and "auto" are converted to 0, | ||
// complex values such as "rotate(1rad)" are returned as is, | ||
// simple values such as "10px" are parsed to Float. | ||
return r === "" || r === "auto" ? 0 : isNaN( parsed = parseFloat(r) ) ? r : parsed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I edited this comment multiple times. Sorry if you read it in between <<
This code won't work in IE6. Just try running the test suite there and it will fail all over the place, because IE6 also returns undefined
and null
. I suggest this line instead
jQuery.isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
It's switched around to make the common case (r
is something number-like) faster. If r
is falsy or auto
it returns 0
else it returns the unparsed value.
P.S. You seem to have a strange character in there after the ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your comments and tests!
(Aptana is driving me nuts, I'm currently searching for another IDE)
As discussed earlier, I'm using isNaN instead of jQuery.isNaN because it is faster in this case. |
lrbabe, did you see jitter's updated comment? |
Landed b9f5e2b |
The complete bug report is to be found here: http://bugs.jquery.com/ticket/7912