-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Description
Describe the bug
When component is mounted in the iframe and internally it uses the document, that document points to parent instance not to the iframe one.
Expected behavour:
Component inside iframe should have its scope as iframe not the parent scope.
Reproduction
<!-- Component.svelte -->
<script>
import { onMount } from "svelte";
let { name } = $props();
onMount(() => {
document.querySelector("#target").textContent = "target=" + name;
});
</script>
{name}
<q><span id="target">inital text</span></q><!-- App.svelte -->
<script>
import Comp from "Comp.svelte";
function onload(ev) {
mount(Comp, { target: ev.target.contentDocument?.body });
}
</script>
<Comp />
<iframe {onload} title="iframe"></iframe>Output
direct "target=iframe"
iframe "initial text"Logs
System Info
System:
OS: Linux 6.12 Arch Linux
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-11390H @ 3.40GHz
Memory: 11.06 GB / 31.09 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 23.9.0 - /usr/bin/node
Yarn: 1.22.22 - /usr/bin/yarn
npm: 11.2.0 - /usr/bin/npm
pnpm: 10.6.2 - /usr/bin/pnpm
Browsers:
Chromium: 134.0.6998.88
npmPackages:
svelte: ^5.23.0 => 5.23.0Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels