chai-dom icon indicating copy to clipboard operation
chai-dom copied to clipboard

.match() doesn't work if the HTMLElement comes from a different Realm

Open jyasskin opened this issue 9 years ago • 1 comments

If an HTML element comes from a different iframe, its constructor won't equal HTMLElement. It'll equal otherWindow.HTMLElement, and that means the test in overwriteMethod('match') returns false when it ought to let the call to .matches() go through.

I'm not sure there's a sensible way to allow this. Testing .constructor.name will miss subclasses of HTMLElement, but you could just test for whether .matches() is callable.

jyasskin avatar Feb 16 '16 01:02 jyasskin

Good points. If you're doing iframe testing, what about also injecting another copy of chai and chai-dom into that frame so the .should chain works? yeah it's more work, but so is the story of using iframes in your same domain (something I've always avoided and it never made much sense to me).

nathanboktae avatar Feb 29 '16 05:02 nathanboktae