UNPKG
domassist
Version:
latest (2.3.2)
2.3.2
2.3.1
2.3.0
2.2.0
2.1.0
2.0.3
2.0.2
2.0.1
2.0.0-rc.2
2.0.0-rc.1
2.0.0-rc.0
1.13.1
1.13.0
1.12.0
1.11.1
1.11.0
1.10.0
1.9.1
1.9.0
1.8.0
1.7.2
1.7.1
1.7.0
1.6.1
1.6.0
1.5.0
1.4.1
1.3.3
1.3.2
1.3.1
1.3.0
1.2.0
1.1.0
1.0.1
Various dom helpers
github.com/firstandthird/domassist
firstandthird/domassist
domassist
/
lib
/
closest.js
16 lines
(11 loc)
•
264 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import
matches
from
'./matches'
;
function
closest
(
el, selector
) {
do
{
if
(
matches
(el, selector)) {
return
el; } el = el.
parentElement
|| el.
parentNode
; }
while
(el !==
null
&& el.
nodeType
===
1
);
return
null
; }
export
default
closest;