Skip to content
Permalink
Browse files

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

  • Loading branch information...
dmethvin committed Aug 30, 2012
1 parent 3a633b0 commit 0ca936d2c911fe037dda3cb9d6e21f6fe1735a2c
Showing with 1 addition and 0 deletions.
  1. +1 −0 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;

This comment has been minimized.

Copy link
@davidmurdoch

davidmurdoch Aug 30, 2012

Contributor

cough_whitespace_cough ;-)

This comment has been minimized.

Copy link
@dmethvin

dmethvin Aug 30, 2012

Author Member

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

This comment has been minimized.

Copy link
@davidmurdoch

davidmurdoch Aug 30, 2012

Contributor

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.

This comment has been minimized.

Copy link
@dmethvin

dmethvin Aug 30, 2012

Author Member

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.

This comment has been minimized.

Copy link
@davidmurdoch

davidmurdoch Aug 30, 2012

Contributor

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

This comment has been minimized.

Copy link
@dmethvin

dmethvin Aug 30, 2012

Author Member

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

for( ; i < 4 ; i += 2 - includeWidth ) {

This comment has been minimized.

Copy link
@gibson042

gibson042 Aug 30, 2012

Member

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?

This comment has been minimized.

Copy link
@dmethvin

dmethvin Aug 30, 2012

Author Member

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

This comment has been minimized.

Copy link
@gibson042

gibson042 Aug 30, 2012

Member

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

which = cssExpand[ i ];
attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;

0 comments on commit 0ca936d

Please sign in to comment.
You can’t perform that action at this time.