Unverified Commit b2e5c014 authored by Erfan's avatar Erfan Committed by GitHub

Add polyfill for `Object.hasOwn` (#60437)

`Object.hasOwn` should be in list of default polyfills. It's a widely
used feature of ES2022

---------
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent 60b60683
......@@ -31,6 +31,7 @@ const NEXT_POLYFILLED_FEATURES = [
'Object.fromEntries',
'Object.getOwnPropertyDescriptor',
'Object.getOwnPropertyDescriptors',
'Object.hasOwn',
'Object.is',
'Object.keys',
'Object.values',
......
......@@ -141,3 +141,23 @@ if (!Array.prototype.at) {
return this[i]
}
}
/**
* Available in:
* Internet Explorer: never
* Edge: 93
* Firefox: 92
* Chrome: 93
* Safari: 15.4
*
* https://caniuse.com/mdn-javascript_builtins_object_hasown
*/
// Modifiled from https://github.com/tc39/proposal-accessible-object-hasownproperty/blob/main/polyfill.js
if (!Object.hasOwn) {
Object.hasOwn = function (object, property) {
if (object == null) {
throw new TypeError('Cannot convert undefined or null to object')
}
return Object.prototype.hasOwnProperty.call(Object(object), property)
}
}
......@@ -29,6 +29,7 @@ import 'core-js/features/object/get-own-property-descriptors'
import 'core-js/features/object/keys'
import 'core-js/features/object/is'
import 'core-js/features/object/values'
import 'core-js/features/object/has-own'
import 'core-js/features/reflect'
import 'core-js/features/regexp'
import 'core-js/features/set'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment