mirror of https://github.com/sveltejs/svelte
fix: handle `<svelte:head>` rendered asynchronously (#17052)
* fix: handle `<svelte:head>` rendered asynchronously * fix testspull/17053/head
parent
da00abe116
commit
cc0143c904
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: handle `<svelte:head>` rendered asynchronously
|
||||
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
let { name, content } = $props();
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<meta name={name} content={content} />
|
||||
</svelte:head>
|
||||
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
let { name, content } = $props();
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<meta name="{name}-1" content="{content}-1" />
|
||||
<meta name="{name}-2" content="{content}-2" />
|
||||
</svelte:head>
|
||||
@ -0,0 +1,23 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, window }) {
|
||||
await tick();
|
||||
|
||||
const head = window.document.head;
|
||||
|
||||
// we don't care about the order, but we want to ensure that the
|
||||
// elements didn't clobber each other
|
||||
for (let n of ['1', '2', '3']) {
|
||||
const a = head.querySelector(`meta[name="a-${n}"]`);
|
||||
assert.equal(a?.getAttribute('content'), n);
|
||||
|
||||
const b1 = head.querySelector(`meta[name="b-${n}-1"]`);
|
||||
assert.equal(b1?.getAttribute('content'), `${n}-1`);
|
||||
|
||||
const b2 = head.querySelector(`meta[name="b-${n}-2"]`);
|
||||
assert.equal(b2?.getAttribute('content'), `${n}-2`);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,11 @@
|
||||
<script lang="ts">
|
||||
import A from './A.svelte';
|
||||
import B from './B.svelte';
|
||||
</script>
|
||||
|
||||
<A name="a-1" content={await 1} />
|
||||
<A name="a-2" content={await 2} />
|
||||
<B name="b-1" content={1} />
|
||||
<A name="a-3" content={await 3} />
|
||||
<B name="b-2" content={2} />
|
||||
<B name="b-3" content={3} />
|
||||
Loading…
Reference in new issue