fgnass / domino

Server-side DOM implementation based on Mozilla's dom.js
BSD 2-Clause "Simplified" License
764 stars 118 forks source link

Fix TypeError in Element.closest when no match is found #154

Closed mdholloway closed 4 years ago

mdholloway commented 4 years ago

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