mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-18 11:28:23 -07:00
47 lines
984 B
JavaScript
47 lines
984 B
JavaScript
define([], function () {
|
|
|
|
function parentWithAttribute(elem, name, value) {
|
|
|
|
while ((value ? elem.getAttribute(name) != value : !elem.getAttribute(name))) {
|
|
elem = elem.parentNode;
|
|
|
|
if (!elem || !elem.getAttribute) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
return elem;
|
|
}
|
|
|
|
function parentWithTag(elem, tagName) {
|
|
|
|
while (elem.tagName != tagName) {
|
|
elem = elem.parentNode;
|
|
|
|
if (!elem) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
return elem;
|
|
}
|
|
|
|
function parentWithClass(elem, className) {
|
|
|
|
while (!elem.classList || !elem.classList.contains(className)) {
|
|
elem = elem.parentNode;
|
|
|
|
if (!elem) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
return elem;
|
|
}
|
|
|
|
return {
|
|
parentWithAttribute: parentWithAttribute,
|
|
parentWithClass: parentWithClass,
|
|
parentWithTag: parentWithTag
|
|
};
|
|
}); |