You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
492 B
17 lines
492 B
"use strict";
|
|
|
|
/**
|
|
* Gets the first containing parent element of a given type for a given child element.
|
|
* @param {HTMLElement} element The child element to find the parent of.
|
|
* @param {string} type The name of the element containing parent to search for.
|
|
*/
|
|
function GetContainingElement(element, type)
|
|
{
|
|
while(element !== null && element.tagName.toLowerCase() !== type.toLowerCase()) {
|
|
element = element.parentNode;
|
|
}
|
|
return element;
|
|
}
|
|
|
|
export default GetContainingElement;
|