MCPcopy Create free account
hub / github.com/DHTMLX/scheduler / closest

Function closest

codebase/sources/dhtmlxscheduler.es.js:4123–4141  ·  view source on GitHub ↗
(element, selector)

Source from the content-addressed store, hash-verified

4121 return activeElement;
4122}
4123function closest(element, selector) {
4124 if (element.closest) {
4125 return element.closest(selector);
4126 } else if (element.matches || element.msMatchesSelector || element.webkitMatchesSelector) {
4127 var el = element;
4128 if (!document.documentElement.contains(el))
4129 return null;
4130 do {
4131 var method = el.matches || el.msMatchesSelector || el.webkitMatchesSelector;
4132 if (method.call(el, selector))
4133 return el;
4134 el = el.parentElement || el.parentNode;
4135 } while (el !== null && el.nodeType === 1);
4136 return null;
4137 } else {
4138 console.error("Your browser is not supported");
4139 return null;
4140 }
4141}
4142function getRootNode(element) {
4143 if (!element) {
4144 return document.body;

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected