1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | var matches_1 = require("./matches");
|
7 | var parents_1 = require("./parents");
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | function closest(element, selector, shouldCheckSelf) {
|
17 | if (shouldCheckSelf === void 0) { shouldCheckSelf = false; }
|
18 | if (!(element && element.nodeType === 1 && selector))
|
19 | return;
|
20 | var parentElements = (shouldCheckSelf ? [element] : []).concat(parents_1.parents(element));
|
21 | for (var i = 0, parent_1; (parent_1 = parentElements[i]); i++) {
|
22 | if (matches_1.matches(parent_1, selector))
|
23 | return parent_1;
|
24 | }
|
25 | }
|
26 | exports.closest = closest;
|
27 |
|
\ | No newline at end of file |