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

Polyfill Element#matches. #400

Merged
merged 3 commits into from
Oct 21, 2020
Merged

Polyfill Element#matches. #400

merged 3 commits into from
Oct 21, 2020

Conversation

bicknellr
Copy link
Collaborator

@bicknellr bicknellr commented Oct 19, 2020

Fixes #397. As mentioned in the bug, Element#matches exists with a vendor-prefixed in the browsers that we polyfill, so this just copies the function over using the standard name.

@bicknellr bicknellr changed the title Polyfill Element#matches Polyfill Element#matches. Oct 19, 2020
@bicknellr bicknellr marked this pull request as ready for review October 20, 2020 00:25
@bicknellr bicknellr requested a review from aomarks as a code owner October 20, 2020 00:25
@bicknellr bicknellr requested a review from sorvell October 20, 2020 00:25

if (!Element_prototype.hasOwnProperty('matches')) {
Element_prototype.matches =
((Element_prototype as any).webkitMatchesSelector as Element['matches']) ??
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add mozMatches (but not sure it's relevant at all)?

Copy link
Collaborator Author

@bicknellr bicknellr Oct 21, 2020

Choose a reason for hiding this comment

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

Firefox 34 has the unprefixed version. I think the webkit... one might even be unnecessary now; the MDN page claims that these two should cover IE9+ though.

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 this pull request may close these issues.

Add polyfill for Element.matches
3 participants