mirror of
https://github.com/codex-team/editor.js
synced 2026-03-18 00:19:53 +01:00
* Toolbox making * Add Toolbox buttons click handler * Toolbar, Toolbox, UI * Updates * update css prefix
24 lines
591 B
JavaScript
24 lines
591 B
JavaScript
/**
|
|
* Element.closest()
|
|
*
|
|
* https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
|
|
*/
|
|
if (!Element.prototype.matches)
|
|
Element.prototype.matches = Element.prototype.msMatchesSelector ||
|
|
Element.prototype.webkitMatchesSelector;
|
|
|
|
if (!Element.prototype.closest)
|
|
Element.prototype.closest = function (s) {
|
|
|
|
var el = this;
|
|
|
|
if (!document.documentElement.contains(el)) return null;
|
|
do {
|
|
|
|
if (el.matches(s)) return el;
|
|
el = el.parentElement || el.parentNode;
|
|
|
|
} while (el !== null);
|
|
return null;
|
|
|
|
};
|