mirror of https://github.com/sveltejs/svelte
parent
e2bbc560e4
commit
5385faf360
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
feat: allow dom elements as `svelte:element` `this` attribute
|
@ -0,0 +1,8 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
ssrHtml: ``,
|
||||||
|
test({ assert, target }) {
|
||||||
|
assert.htmlEqual(target.innerHTML, `<div><b>children</b><p>children</p></div>`);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,13 @@
|
|||||||
|
<script>
|
||||||
|
let div = $state(null);
|
||||||
|
|
||||||
|
$effect(()=>{
|
||||||
|
const to_add = document.createElement("div");
|
||||||
|
to_add.innerHTML=`<b>children</b>`;
|
||||||
|
div = to_add;
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:element this={div}>
|
||||||
|
<p>children</p>
|
||||||
|
</svelte:element>
|
@ -0,0 +1,8 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
ssrHtml: `<div><p>children</p></div>`,
|
||||||
|
test({ assert, target }) {
|
||||||
|
assert.htmlEqual(target.innerHTML, `<div><b>children</b><p>children</p></div>`);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,13 @@
|
|||||||
|
<script>
|
||||||
|
let div = $state(null);
|
||||||
|
|
||||||
|
$effect(()=>{
|
||||||
|
const to_add = document.createElement("div");
|
||||||
|
to_add.innerHTML=`<b>children</b>`;
|
||||||
|
div = to_add;
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:element this={div ?? "div"}>
|
||||||
|
<p>children</p>
|
||||||
|
</svelte:element>
|
Loading…
Reference in new issue