aboutsummaryrefslogtreecommitdiff
path: root/assets_src/js/lib/dom.js
blob: 33845af1eb3cdf7d0ae4ed5cafd19317c94d45f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
export function ready(fn) {
	document.addEventListener('DOMContentLoaded', (e) => {
		fn();
	}, false);
}

export function closest(el, fn) {
	while (el) {
		if (fn(el)) {
			return el;
		}
		el = el.parentNode
	}
}