-
Notifications
You must be signed in to change notification settings - Fork 12
Closed
Description
Constructors are not shared between window instances. So for example if you have an HTML element in an iframe this check will fail:
iframeDiv instanceof window.Element
Read more here
I suggest using a different strategy to check if the given parameter is an Element. For example, using tagName
MWE:
import { ResizeObserver } from "resize-observer";
document.getElementById("app").innerHTML = `
<iframe></iframe>
`;
const resizeObserver = new ResizeObserver((entries) => {
for (let entry of entries) {
console.log(entry);
}
});
const iframe = document.querySelector("iframe");
resizeObserver.observe(iframe.contentDocument.body);
iframe.contentDocument.body.style.width = "300px";
Codesanbox here
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels