MCPcopy Index your code
hub / github.com/SortableJS/Sortable / closest

Function closest

src/utils.js:46–69  ·  view source on GitHub ↗
(/**HTMLElement*/el, /**String*/selector, /**HTMLElement*/ctx, includeCTX)

Source from the content-addressed store, hash-verified

44}
45
46function closest(/**HTMLElement*/el, /**String*/selector, /**HTMLElement*/ctx, includeCTX) {
47 if (el) {
48 ctx = ctx || document;
49
50 do {
51 if (
52 selector != null &&
53 (
54 selector[0] === '>' ?
55 el.parentNode === ctx && matches(el, selector) :
56 matches(el, selector)
57 ) ||
58 includeCTX && el === ctx
59 ) {
60 return el;
61 }
62
63 if (el === ctx) break;
64 /* jshint boss:true */
65 } while (el = getParentOrHost(el));
66 }
67
68 return null;
69}
70
71const R_SPACE = /\s+/g;
72

Callers 3

Sortable.jsFile · 0.90
getChildFunction · 0.70

Calls 2

matchesFunction · 0.70
getParentOrHostFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…