Currently, when Element.closest reaches the top of the DOM tree without
finding a match, a TypeError is thrown when attempting to read the
'matches' property of the Document node's parentNode (null). This patch
adds a check that el.parentNode exists to the loop conditional so that
we break out as expected without throwing.
Currently, when Element.closest reaches the top of the DOM tree without finding a match, a TypeError is thrown when attempting to read the 'matches' property of the Document node's parentNode (null). This patch adds a check that el.parentNode exists to the loop conditional so that we break out as expected without throwing.
Bug: T240682