Skip to content

Commit

Permalink
add a workaround for V8 ~ Chrome 53 bug with non-writable prototype o…
Browse files Browse the repository at this point in the history
…f some methods, close #1083
  • Loading branch information
zloirock committed May 24, 2022
1 parent 3b9b0bf commit 230fa4c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Changelog
##### Unreleased
- Nothing
- Added a workaround for V8 ~ Chrome 53 bug with non-writable prototype of some methods, [#1083](https://github.com/zloirock/core-js/issues/1083)

##### [3.22.6 - 2022.05.23](https://github.com/zloirock/core-js/releases/tag/v3.22.6)
- Fixed possible double call of `ToNumber` conversion on arguments of `Math.{ fround, trunc }` polyfills
Expand Down
11 changes: 6 additions & 5 deletions packages/core-js/internals/make-built-in.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ var makeBuiltIn = module.exports = function (value, name, options) {
if (CONFIGURABLE_LENGTH && options && hasOwn(options, 'arity') && value.length !== options.arity) {
defineProperty(value, 'length', { value: options.arity });
}
if (options && hasOwn(options, 'constructor') && options.constructor) {
if (DESCRIPTORS) try {
defineProperty(value, 'prototype', { writable: false });
} catch (error) { /* empty */ }
} else value.prototype = undefined;
try {
if (options && hasOwn(options, 'constructor') && options.constructor) {
if (DESCRIPTORS) defineProperty(value, 'prototype', { writable: false });
// in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable
} else if (value.prototype) value.prototype = undefined;
} catch (error) { /* empty */ }
var state = enforceInternalState(value);
if (!hasOwn(state, 'source')) {
state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
Expand Down

0 comments on commit 230fa4c

Please sign in to comment.