Skip to content

Commit

Permalink
Fixing strange iOS7 bug with Math.abs on non-primitive numbers.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewplummer committed Dec 12, 2013
1 parent cd425e1 commit 11fa382
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ v1.4.2
- Bower.json now points to unminified script (#388)
- Date.create(null) is now interpeted as a time stamp (#387)
- Fix for ambiguous years not working with `Date#past/future` (#383)
- Fix for odd iOS7 bug with `Number#abs` (#400)

v1.4.1
======
Expand Down
6 changes: 5 additions & 1 deletion lib/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,11 @@
});
extendSimilar(number, true, true, 'abs,pow,sin,asin,cos,acos,tan,atan,exp,pow,sqrt', function(methods, name) {
methods[name] = function(a, b) {
return math[name](this, a, b);
// Note that .valueOf() here is only required due to a
// very strange bug in iOS7 that only occurs occasionally
// in which Math.abs() called on non-primitive numbers
// returns a completely different number (Issue #400)
return math[name](this.valueOf(), a, b);
}
});
}
Expand Down

0 comments on commit 11fa382

Please sign in to comment.