closest
closest copied to clipboard
Support shadowDOM elements
Closest
is being used by https://github.com/zenorocha/delegate which I am using in my project. Unfortunately delegate
doesn't work for shadowDOM elements because of the strict checking closest
is doing with the global document
object.
Seems like a good idea to me but is there a simpler way maybe to do the check? Like comparing nodeType
? It says here that shadow root is 11
while (parent && parent.nodeType === 1)
I agree with @ryanve this doesn't look like a very clean approach.
Closest is being used by https://github.com/bpmn-io/min-dom.
https://github.com/bpmn-io/min-dom/issues/5 is also related.