I have the following structure:
Content here
Content here&l
-
i wrote a litte-snipped to travel through DOM to find the first matching parentNode.
Hope this helps someone, sometime.
(/¯◡ ‿ ◡)⊃━☆゚. * ・ 。゚,
function getFirstParentMatch(element, selector) {
if (!element) {return element};
element.matches(selector) || (element = (element.nodeName.toLowerCase() === 'html' ? false : getFirstParent(element.parentNode, selector)));
return element;
}