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

Add isPolyfilled method #193

Merged
merged 3 commits into from
Mar 27, 2024
Merged

Conversation

didoo
Copy link
Contributor

@didoo didoo commented Mar 27, 2024

Description

This PR adds a isPolyfilled function to the public methods exposed by the polyfill.
The functions tests if the Popover API has been polyfilled, and it can be used to execute conditional code depending on if the Popover API is polyfilled or is native.

Related Issue(s)

#189

Copy link

netlify bot commented Mar 27, 2024

Deploy Preview for popover-polyfill ready!

Name Link
🔨 Latest commit 5ad1870
🔍 Latest deploy log https://app.netlify.com/sites/popover-polyfill/deploys/66044096eb9d290008bdd5d6
😎 Deploy Preview https://deploy-preview-193--popover-polyfill.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

src/popover.ts Outdated
return (
document.body &&
document.body.showPopover &&
!document.body.showPopover.toString().match(/native code/i)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not particularly attached to this implementation, so if you have suggestions or think this code could/should be written in a different way, just let me know.

Copy link
Collaborator

@keithamus keithamus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

@didoo
Copy link
Contributor Author

didoo commented Mar 27, 2024

@keithamus @jgerigmeyer I was looking at ways to do automatic testing of the function but from what I see with the current suite of tests it's not possible. Or am I missing something?

@keithamus
Copy link
Collaborator

Yeah we don't really have unit tests. Frankly I'm not especially concerned about tests for this amount of code. It'll get shaken out during integration.

@jgerigmeyer jgerigmeyer linked an issue Mar 27, 2024 that may be closed by this pull request
src/popover.ts Outdated Show resolved Hide resolved
@jgerigmeyer jgerigmeyer merged commit 94f6339 into oddbird:main Mar 27, 2024
6 of 7 checks passed
@didoo
Copy link
Contributor Author

didoo commented Mar 27, 2024

@jgerigmeyer there was a linting error that I was looking to fix but the PR is already merged. Has it been already fixed (automatically maybe)? Is it OK to leave it as it is?

@jgerigmeyer
Copy link
Member

@jgerigmeyer there was a linting error that I was looking to fix but the PR is already merged. Has it been already fixed (automatically maybe)? Is it OK to leave it as it is?

Yeah that's fine -- I merged it and then pushed a quick fix 👍

Thanks for your contribution!

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

Successfully merging this pull request may close these issues.

Is there a way to detect if the Popover API is polyfilled ot not?
3 participants