Skip to content

Commit

Permalink
Number: Fixed wrapConstructor to not require true ES5.
Browse files Browse the repository at this point in the history
See #365.
  • Loading branch information
ljharb committed Oct 23, 2015
1 parent 8544a68 commit 01cc9f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ In both browser and node you may also want to include `unorm`; see the [`String.
* `RegExp.prototype`:
* `flags` (requires ES5) ([a standalone shim is also available](https://github.com/es-shims/RegExp.prototype.flags))
* `Number`:
* binary and octal literals: `Number('0b1')` and `Number('0o7')` (requires ES5 property descriptor support)
* binary and octal literals: `Number('0b1')` and `Number('0o7')`
* `EPSILON`
* `MAX_SAFE_INTEGER`
* `MIN_SAFE_INTEGER`
Expand Down
17 changes: 12 additions & 5 deletions es6-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,17 @@
// sets up proper prototype chain where possible
Object.setPrototypeOf(original, replacement);
}
_forEach(Object.getOwnPropertyNames(original), function (key) {
if (key in noop || keysToSkip[key]) { return; }
Value.proxy(original, key, replacement);
});
if (supportsDescriptors) {
_forEach(Object.getOwnPropertyNames(original), function (key) {
if (key in noop || keysToSkip[key]) { return; }
Value.proxy(original, key, replacement);
});
} else {
_forEach(Object.keys(original), function (key) {
if (key in noop || keysToSkip[key]) { return; }
replacement[key] = original[key];
});
}
replacement.prototype = original.prototype;
Value.redefine(original.prototype, 'constructor', replacement);
};
Expand Down Expand Up @@ -1132,7 +1139,7 @@
}, true);
}

if (supportsDescriptors && (Number('0o10') !== 8 || Number('0b10') !== 2)) {
if (Number('0o10') !== 8 || Number('0b10') !== 2) {
var OrigNumber = Number;
var binaryRegex = /^0b/i;
var octalRegex = /^0o/i;
Expand Down

0 comments on commit 01cc9f5

Please sign in to comment.