nathanboktae / chai-dom

DOM assertions for the Chai assertion library using vanilla JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

jyasskin opened this issue · 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.

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).