DanSnow / vue-recaptcha

Google ReCAPTCHA component for Vue.js
http://dansnow.github.io/vue-recaptcha/
MIT License
860 stars 135 forks source link

Object.hasOwn is not a function #1277

Open BoBo-Git opened 11 months ago

BoBo-Git commented 11 months ago

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...

Teages commented 11 months ago

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

BoBo-Git commented 11 months ago

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!

phanthai12 commented 6 months ago

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

umaraziz0 commented 1 month ago

Same bug here