access-nyc-patterns
Version:
User Interface Patterns for Benefits Access
25 lines (22 loc) • 744 B
JavaScript
;
/**
* Polyfill for Element.prototype.matches()
* https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
*/
/* eslint-disable no-undef */
if (!Element.prototype.matches)
Element.prototype.matches =
Element.prototype.matchesSelector ||
Element.prototype.mozMatchesSelector ||
Element.prototype.msMatchesSelector ||
Element.prototype.oMatchesSelector ||
Element.prototype.webkitMatchesSelector ||
function(s) {
let matches = (this.document || this.ownerDocument)
.querySelectorAll(s);
let i = matches.length;
// eslint-disable-next-line no-empty
while (--i >= 0 && matches.item(i) !== this) {}
return i > -1;
};
/* eslint-enable no-undef */