mirror of https://github.com/sveltejs/svelte
html anchor in head (#5071)
parent
f739b4772a
commit
62345432ac
@ -1,33 +1,3 @@
|
||||
export default {
|
||||
html: `
|
||||
<button>Switch</button>
|
||||
<p>Another first line</p>
|
||||
<p>This line should be last.</p>
|
||||
`,
|
||||
async test({ assert, target, window }) {
|
||||
const btn = target.querySelector("button");
|
||||
const clickEvent = new window.MouseEvent("click");
|
||||
|
||||
await btn.dispatchEvent(clickEvent);
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button>Switch</button>
|
||||
<p>First line</p>
|
||||
<p>This line should be last.</p>
|
||||
`
|
||||
);
|
||||
|
||||
await btn.dispatchEvent(clickEvent);
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button>Switch</button>
|
||||
<p>Another first line</p>
|
||||
<p>This line should be last.</p>
|
||||
`
|
||||
);
|
||||
},
|
||||
html: `<p>x<span>baz</span></p>`
|
||||
};
|
||||
|
@ -1,17 +1 @@
|
||||
<script>
|
||||
import Component from './Component.svelte';
|
||||
|
||||
let content1 = `<p>First line</p>`;
|
||||
let content2 = `<p>Another first line</p>`
|
||||
|
||||
let show = false;
|
||||
$: content = show ? content1 : content2;
|
||||
</script>
|
||||
|
||||
<button on:click={() => show = !show}>
|
||||
Switch
|
||||
</button>
|
||||
|
||||
<Component>
|
||||
{@html content}
|
||||
</Component>
|
||||
<p>{@html 'x'}<span>baz</span></p>
|
@ -0,0 +1,16 @@
|
||||
export default {
|
||||
async test({ assert, target, window }) {
|
||||
const btn = target.querySelector("button");
|
||||
const clickEvent = new window.MouseEvent("click");
|
||||
|
||||
assert.equal(window.document.head.innerHTML.includes('<style>body { color: blue; }</style><style>body { color: green; }</style>'), true);
|
||||
|
||||
await btn.dispatchEvent(clickEvent);
|
||||
|
||||
assert.equal(window.document.head.innerHTML.includes('<style>body { color: red; }</style><style>body { color: green; }</style>'), true);
|
||||
|
||||
await btn.dispatchEvent(clickEvent);
|
||||
|
||||
assert.equal(window.document.head.innerHTML.includes('<style>body { color: blue; }</style><style>body { color: green; }</style>'), true);
|
||||
},
|
||||
};
|
@ -0,0 +1,16 @@
|
||||
<script>
|
||||
let content1 = `<style>body { color: red; }</style>`;
|
||||
let content2 = `<style>body { color: blue; }</style>`
|
||||
|
||||
let show = false;
|
||||
$: content = show ? content1 : content2;
|
||||
</script>
|
||||
|
||||
<button on:click={() => show = !show}>
|
||||
Switch
|
||||
</button>
|
||||
|
||||
<svelte:head>
|
||||
{@html content}
|
||||
<style>body { color: green; }</style>
|
||||
</svelte:head>
|
@ -1,3 +1,33 @@
|
||||
export default {
|
||||
html: `<p>x<span>baz</span></p>`
|
||||
html: `
|
||||
<button>Switch</button>
|
||||
<p>Another first line</p>
|
||||
<p>This line should be last.</p>
|
||||
`,
|
||||
async test({ assert, target, window }) {
|
||||
const btn = target.querySelector("button");
|
||||
const clickEvent = new window.MouseEvent("click");
|
||||
|
||||
await btn.dispatchEvent(clickEvent);
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button>Switch</button>
|
||||
<p>First line</p>
|
||||
<p>This line should be last.</p>
|
||||
`
|
||||
);
|
||||
|
||||
await btn.dispatchEvent(clickEvent);
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button>Switch</button>
|
||||
<p>Another first line</p>
|
||||
<p>This line should be last.</p>
|
||||
`
|
||||
);
|
||||
},
|
||||
};
|
||||
|
@ -1 +1,17 @@
|
||||
<p>{@html 'x'}<span>baz</span></p>
|
||||
<script>
|
||||
import Component from './Component.svelte';
|
||||
|
||||
let content1 = `<p>First line</p>`;
|
||||
let content2 = `<p>Another first line</p>`
|
||||
|
||||
let show = false;
|
||||
$: content = show ? content1 : content2;
|
||||
</script>
|
||||
|
||||
<button on:click={() => show = !show}>
|
||||
Switch
|
||||
</button>
|
||||
|
||||
<Component>
|
||||
{@html content}
|
||||
</Component>
|
Loading…
Reference in new issue