instanceof checks in iframes
Bug description
There are some rare use cases where elements are rendered into a different iframe. For example: https://github.com/ryanseddon/react-frame-component . Considering it has 1.8k stars, I guess it's common enough of a use case.
When done so, expressions such as element instanceof HTMLElement would evaluate to always false because an iframe's HTMLElement is not the same as window/globalThis.HTMLElement. In such cases, one usually needs to either:
- Take a custom optional
windowas option and doel instanceof customWindow.HTMLElement - Or if that's not needed (if there are workarounds for all global variable/class/etc. usages), write code accordingly such as
el instanceof el.ownerDocument.defaultView.HTMLElement. - Or avoid such strict checks and assume it's an element.
Currently wavesurfer doesn't work in such cases because, for example, parentFromOptionsContainer uses instanceof HTMLElement which always returns false. One would hope there'd be a workaround, but there sadly isn't because the other fallback document.querySelector would fail too because document !== iframe.document, so it would search in the wrong document.
Thanks for the heads up. Do we need this issue though? I don't see it as something actionable for us.
I (or somebody else) could eventually make a PR to either make those checks less dependent on globalThis, or if that isn't possible for all cases, I could introduce an option such as window, as done by some component libraries or css-in-js libraries.