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

fix: querySelector APIs support null/undefined (closes #104) #105

Merged
merged 1 commit into from
Jun 5, 2023

Conversation

p-ob
Copy link
Contributor

@p-ob p-ob commented Jun 2, 2023

To demonstrate this, you can see this in action if you go to the demo in a browser that doesn't natively implement popover, and in the console execute:

document.querySelector(null);

This causes some interop issues with other 3rd party libraries.

Expected behavior

document.querySelector does not throw an error, and returns null.

Actual behavior

Error thrown: Uncaught TypeError: can't access property "includes", selector is null

Firefox:
image

@netlify
Copy link

netlify bot commented Jun 2, 2023

Deploy Preview for popover-polyfill failed.

Name Link
🔨 Latest commit 1bf820a
🔍 Latest deploy log https://app.netlify.com/sites/popover-polyfill/deploys/647a2058649be00008cc6bd5

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.

I wonder who's calling querySelector with null, but, defence in depth 😂

@p-ob
Copy link
Contributor Author

p-ob commented Jun 2, 2023

I wonder who's calling querySelector with null, but, defence in depth 😂

We use a tool called Appcues, and I'm sure it's technically a bug that doesn't actually manifest in any user issues. But the web supports it so 🤷‍♂️.

@jgerigmeyer jgerigmeyer changed the base branch from main to query-selector-bug June 5, 2023 21:47
@jgerigmeyer jgerigmeyer merged commit 25f57ca into oddbird:query-selector-bug Jun 5, 2023
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.

Polyfill breaks other libraries that pass null/undefined to document.querySelector
3 participants