| 16 | } |
| 17 | |
| 18 | function matches(/**HTMLElement*/el, /**String*/selector) { |
| 19 | if (!selector) return; |
| 20 | |
| 21 | selector[0] === '>' && (selector = selector.substring(1)); |
| 22 | |
| 23 | if (el) { |
| 24 | try { |
| 25 | if (el.matches) { |
| 26 | return el.matches(selector); |
| 27 | } else if (el.msMatchesSelector) { |
| 28 | return el.msMatchesSelector(selector); |
| 29 | } else if (el.webkitMatchesSelector) { |
| 30 | return el.webkitMatchesSelector(selector); |
| 31 | } |
| 32 | } catch(_) { |
| 33 | return false; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | return false; |
| 38 | } |
| 39 | |
| 40 | function getParentOrHost(el) { |
| 41 | return (el.host && el !== document && el.host.nodeType && el.host !== el) |