From bf31417781833ac50b43f896b0aadbb4cb3ee718 Mon Sep 17 00:00:00 2001 From: Taye Adeyemi Date: Mon, 29 Dec 2014 13:19:24 +0000 Subject: [PATCH] Add another matchesSelector polyfill that works better with the shadow DOM polyfill --- interact.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/interact.js b/interact.js index a440fc9df..23bd2bf91 100644 --- a/interact.js +++ b/interact.js @@ -5458,6 +5458,19 @@ } function matchesSelector (element, selector, nodeList) { + // The CustomElements polyfill for Element.matches doesn't + // work with Shadow DOM selectors like :host, /deep/, etc. + if (window !== realWindow + && /:host|::content|::shadow|\/deep\//.test(selector)) { + var matches = (element.parentNode || element.ownerDocument).querySelectorAll(selector); + + for (var i = 0; i < matches.length; i++) { + if (matches[i] === element) { return true; } + } + + return false; + } + if (ie8MatchesSelector) { return ie8MatchesSelector(element, selector, nodeList); }