Financial-Times / ftdomdelegate

Create and manage a DOM event delegator
MIT License
320 stars 36 forks source link

Look for Element in node's global obj if not found #87

Closed laurieboyes closed 5 years ago

laurieboyes commented 7 years ago

I'd like to test my ftdomdelegate-using client-side code on the server using JSDom or something similar.

When defining the matches function, we look for Element on the window. On server-side code, this results in a ReferenceError.

This change allows me to still test my client-side code using JSDom, as long as, as part of my test setup, I make my JSDom document's Element property a property of the node global object.

Would this be an acceptable addition?

rowanbeentje commented 7 years ago

Did you consider a typeof window check first, just to avoid the try/catch which engines tend to not like? Would that be better?

Otherwise LGTM, can't see a problem with this!

notlee commented 5 years ago

Ændrew had a similar issue with o-grid; I suspect this will sort it it!

Hi Laurie, hi!! 👋