From d148b53f3b0d2704e4c0146a946e42c2eaaa6e3f Mon Sep 17 00:00:00 2001 From: Valentyne Stigloher Date: Tue, 12 Mar 2024 13:57:38 +0100 Subject: [PATCH] (polyfill) simple polyfill for Object.hasOwn --- nuxt.config.ts | 1 + plugins/polyfill.ts | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 plugins/polyfill.ts diff --git a/nuxt.config.ts b/nuxt.config.ts index 21dc2b4f3..4f7c3fd54 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -166,6 +166,7 @@ const nuxtConfig: NuxtConfig = { '~/assets/style.scss', ], plugins: [ + { src: '~/plugins/polyfill.ts', mode: 'client' }, { src: '~/plugins/axios.js' }, { src: '~/plugins/globals.ts' }, { src: '~/plugins/auth.ts' }, diff --git a/plugins/polyfill.ts b/plugins/polyfill.ts new file mode 100644 index 000000000..2df3a70f2 --- /dev/null +++ b/plugins/polyfill.ts @@ -0,0 +1,9 @@ +export default (): void => { + if (!Object.prototype.hasOwnProperty.call(Object, 'hasOwn')) { + Object.defineProperty(Object, 'hasOwn', { + value: (object: object, property: PropertyKey) => { + return Object.prototype.hasOwnProperty.call(object, property); + }, + }); + } +};