Skip to content

Instantly share code, notes, and snippets.

@PatrickJS
Created August 9, 2020 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatrickJS/dc5ba3c9391c8c2ac7b54a14347cb14f to your computer and use it in GitHub Desktop.
Save PatrickJS/dc5ba3c9391c8c2ac7b54a14347cb14f to your computer and use it in GitHub Desktop.
angular/packages/elements/src/utils.ts
let matches = null;
export function matchesSelector(element: Element, selector: string): boolean {
if (!matches) {
const elProto = Element.prototype as any;
matches = elProto.matches || elProto.matchesSelector || elProto.mozMatchesSelector ||
elProto.msMatchesSelector || elProto.oMatchesSelector || elProto.webkitMatchesSelector;
}
return matches.call(element, selector);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment