Skip to content

Commit

Permalink
[Fix] IE 8: Number(new Number(1)) was throwing. More NFE madness.
Browse files Browse the repository at this point in the history
Relates to paulmillr#365.
  • Loading branch information
ljharb committed Oct 26, 2015
1 parent bdc0510 commit 886f30d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions es6-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@
};
var NumberShim = (function () {
// this is wrapped in an IIFE because of IE 6-8's wacky scoping issues with named function expressions.
return function Number(value) {
var NumberShim = function Number(value) {
var primValue = Type.primitive(value) ? value : toPrimitive(value, 'number');
if (typeof primValue === 'string') {
if (isBinary(primValue)) {
Expand All @@ -1173,16 +1173,17 @@
}
var receiver = this;
var valueOfSucceeds = valueOrFalseIfThrows(function () {
Number.prototype.valueOf.call(receiver);
OrigNumber.prototype.valueOf.call(receiver);
return true;
});
if (receiver instanceof Number && !valueOfSucceeds) {
if (receiver instanceof NumberShim && !valueOfSucceeds) {
return new OrigNumber(primValue);
}
/* jshint newcap: false */
return OrigNumber(primValue);
/* jshint newcap: true */
};
return NumberShim;
}());
wrapConstructor(OrigNumber, NumberShim, {});
/*globals Number: true */
Expand Down

0 comments on commit 886f30d

Please sign in to comment.