vue-recaptcha icon indicating copy to clipboard operation
vue-recaptcha copied to clipboard

Object.hasOwn is not a function

Open BoBo-Git opened this issue 2 years ago • 4 comments

Description

When using Safari: Version 15.3 (17612.4.9.1.8) MacOS: 12.2.1 (21D62), visit the page of mine project, will show error Object.hasOwn is not a function on the page.

Minimal Reproducible Example

Use not support Object.hasOwn browsers visit this library's official site, the example can not show on the page.

System info

Safari: Version 15.3 (17612.4.9.1.8) MacOS: 12.2.1 (21D62)

Maybe other not support function Object.hasOwn browsers...

BoBo-Git avatar Aug 01 '23 09:08 BoBo-Git

Object: hasOwn does not support safari <= 15.3

I think we can replace this line with

const isLoaded = window['grecaptcha'] && (window.grecaptcha['execute'] instanceof Function)

it may be a bad idea to avoid new features for supporting old browsers, so I use polyfills to fix it.

{
    targets: [
      'last 2 versions and not dead',
      '> 0.3%',
      'Firefox ESR',
      'iOS >= 13.2',
    ],
    polyfills: [
      'es.object.has-own',
    ],
    modernPolyfills: [
      'es.object.has-own',
    ],
  }

I don't know why es.object.has-own is not included by default unless I specify it. hope it helps you

Teages avatar Aug 02 '23 16:08 Teages

Object: hasOwn does not support safari <= 15.3

I think we can replace this line with

const isLoaded = window['grecaptcha'] && (window.grecaptcha['execute'] instanceof Function)

it may be a bad idea to avoid new features for supporting old browsers, so I use polyfills to fix it.

{
    targets: [
      'last 2 versions and not dead',
      '> 0.3%',
      'Firefox ESR',
      'iOS >= 13.2',
    ],
    polyfills: [
      'es.object.has-own',
    ],
    modernPolyfills: [
      'es.object.has-own',
    ],
  }

I don't know why es.object.has-own is not included by default unless I specify it. hope it helps you

Thanks for your reply!

Currently, I am making a separate judgment. If Object.hasOwn does not exist, I will manually override it to achieve the result. This has temporarily solved my problem.

But I think as a general-purpose library, it's important to consider some compatibility while using new features - after all, Safari Version <= 15.3 isn't too old.

I also introduced Polyfills but didn't notice the need to specifically configure Object.haOwn, I'll give it a try, thanks again for the solution!

BoBo-Git avatar Aug 04 '23 08:08 BoBo-Git

Same bug, and DanSnow continue can't fix it?

phanthai12 avatar Dec 26 '23 08:12 phanthai12

Same bug here

umaraziz0 avatar Jun 05 '24 02:06 umaraziz0