getParentsUntil
Finds all the ancestors of an element up until the element matched by the specified selector.
- Use
Node.parentNodeand awhileloop to move up the ancestor tree of the element. - Use
Array.prototype.unshift()to add each new ancestor to the start of the array. - Use
Element.matches()to check if the current element matches the specifiedselector.