Skip to content
Browse files

Fix #12370. Explicitly coerce bool/undef to integer.

  • Loading branch information...
1 parent 3a633b0 commit 0ca936d2c911fe037dda3cb9d6e21f6fe1735a2c @dmethvin dmethvin committed Aug 30, 2012
Showing with 1 addition and 0 deletions.
  1. +1 −0 src/effects.js
View
1 src/effects.js
@@ -540,6 +540,7 @@ function genFx( type, includeWidth ) {
// if we include width, step value is 1 to do all cssExpand values,
// if we don't include width, step value is 2 to skip over Left and Right
+ includeWidth = includeWidth? 1 : 0;
@davidmurdoch
davidmurdoch added a note Aug 30, 2012

coughwhitespacecough ;-)

@dmethvin
jQuery Foundation member
dmethvin added a note Aug 30, 2012

My only defense is that I got distracted by the thought of using ~~includeWidth in the for loop. It saves a byte but I was concerned that if Android 2.1 is dumb it might also be dumber. I think we're at 1.8.1 now

@davidmurdoch
davidmurdoch added a note Aug 30, 2012

Why not just update all calls to genFx to include the includeWith parameter as a Number?

In fact, you could just change includeWidth to stepValue and update all calls to genFx to pass a stepValue (1 or 2). I image there may be a couple of gzipped bytes to be saved here.

@dmethvin
jQuery Foundation member
dmethvin added a note Aug 30, 2012

Could be, but I was primarily looking for a simple and safe fix for 1.8.1. Logically, includeWidth should be boolean; passing in a number doesn't make its purpose as clear.

@davidmurdoch
davidmurdoch added a note Aug 30, 2012

That's why I suggested changing the parameter name to stepValue. :-)

@dmethvin
jQuery Foundation member
dmethvin added a note Aug 30, 2012

That's exposing too much of the internal workings imo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
for( ; i < 4 ; i += 2 - includeWidth ) {
@gibson042
jQuery Foundation member
gibson042 added a note Aug 30, 2012

If a browser really is failing on ToNumber(boolean) coercion in this expression, we'll have to clean up the other places in which we rely on that behavior. Is there any way for us to get strong confirmation?

@dmethvin
jQuery Foundation member
dmethvin added a note Aug 30, 2012

It may have failed on converting undefined instead, I just saw the boolean call first. There are several genFx() calls with just one arg. Kinda makes me wonder how it ever worked... is this covered by a unit test? /cc @gnarf37

@gibson042
jQuery Foundation member
gibson042 added a note Aug 30, 2012

Yep, that would do it. And undefined casts to NaN, so there's your problem right there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
which = cssExpand[ i ];
attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;

0 comments on commit 0ca936d

Please sign in to comment.
Something went wrong with that request. Please try again.