Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object.hasOwn is not a function #1277

Open
BoBo-Git opened this issue Aug 1, 2023 · 4 comments
Open

Object.hasOwn is not a function #1277

BoBo-Git opened this issue Aug 1, 2023 · 4 comments
Labels

Comments

@BoBo-Git
Copy link

BoBo-Git commented Aug 1, 2023

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 BoBo-Git added the bug label Aug 1, 2023
@Teages
Copy link

Teages commented Aug 2, 2023

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
Copy link
Author

BoBo-Git commented Aug 4, 2023

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
Copy link

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

@umaraziz0
Copy link

Same bug here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants