mirror of https://github.com/sveltejs/svelte
Use SSR rendered as initial html for runtime hydration test (#4444)
parent
8dd9c1b098
commit
3f990a96ba
@ -1,3 +0,0 @@
|
|||||||
import Foo from './Foo.svelte';
|
|
||||||
|
|
||||||
export default { Foo };
|
|
@ -0,0 +1,5 @@
|
|||||||
|
<script context="module">
|
||||||
|
import Foo from './Foo.svelte';
|
||||||
|
|
||||||
|
export const Components = { Foo };
|
||||||
|
</script>
|
@ -1,4 +1,4 @@
|
|||||||
export default {
|
export default {
|
||||||
html: '<text>hello world</text>',
|
html: '<svg><text>hello world</text></svg>',
|
||||||
preserveIdentifiers: true
|
preserveIdentifiers: true
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
let foo = 'hello world'
|
let foo = 'hello world'
|
||||||
</script>
|
</script>
|
||||||
|
<svg>
|
||||||
<text>{foo}</text>
|
<text>{foo}</text>
|
||||||
|
</svg>
|
@ -1,9 +1,33 @@
|
|||||||
export default {
|
export default {
|
||||||
skip_if_ssr: true,
|
ssrHtml: `
|
||||||
|
<noscript>foo</noscript>
|
||||||
|
|
||||||
html: `
|
<div>foo<noscript>foo</noscript></div>
|
||||||
<div>foo</div>
|
|
||||||
|
|
||||||
<div>foo<div>foo</div></div>
|
<div>foo<div>foo<noscript>foo</noscript></div></div>
|
||||||
`
|
`,
|
||||||
|
test({ assert, target, compileOptions }) {
|
||||||
|
// if created on client side, should not build noscript
|
||||||
|
if (!compileOptions.hydratable) {
|
||||||
|
assert.equal(target.querySelectorAll('noscript').length, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// it's okay not to remove the node during hydration
|
||||||
|
// will not be seen by user anyway
|
||||||
|
removeNoScript(target);
|
||||||
|
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<div>foo</div>
|
||||||
|
<div>foo<div>foo</div></div>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function removeNoScript(target) {
|
||||||
|
target.querySelectorAll('noscript').forEach(elem => {
|
||||||
|
elem.parentNode.removeChild(elem);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
Reference in new issue