nathanboktae / chai-dom

DOM assertions for the Chai assertion library using vanilla JavaScript
Other
76 stars 26 forks source link

Implement method override check without instanceof #32

Closed rayd closed 6 years ago

rayd commented 6 years ago

This is a proposed fix for #8: In order to support making assertions against elements that exist within another iframe, we cannot use instanceof to check if we should override the Assertion method. This fails because window.HTMLElement !== otherWindow.HTMLElement. Instead use the nodeType property to check if we're dealing with an element, or for the NodeList check use the class name.

nathanboktae commented 6 years ago

Thanks! I like this implementation. Did you test this with jsdom by chance?

rayd commented 6 years ago

I haven't actually - just with Chrome, Firefox and PhantomJS - any suggestions for testing with jsdom?

nathanboktae commented 6 years ago

I did a manual sanity test and it looks fine. I should add another test target or such for jsdom.

rayd commented 6 years ago

:+1: awesome, thank you for being so responsive!

nathanboktae commented 6 years ago

No problem! 1.8.0 is released with the improvement. Thanks for the contribution.