mirror of
https://github.com/ConnectedHumber/Air-Quality-Web
synced 2024-11-29 07:23:00 +00:00
16 lines
492 B
JavaScript
16 lines
492 B
JavaScript
"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;
|