mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
Merge branch 'master' into codegen
This commit is contained in:
commit
263a34d35c
@ -209,8 +209,9 @@ export default function dom(
|
||||
var nodes = @children( options.target );
|
||||
options.hydrate ? this._fragment.claim( nodes ) : this._fragment.create();
|
||||
nodes.forEach( @detachNode );
|
||||
`
|
||||
: deindent`
|
||||
` :
|
||||
deindent`
|
||||
${options.dev && `if ( options.hydrate ) throw new Error( 'options.hydrate only works if the component was compiled with the \`hydratable: true\` option' );`}
|
||||
this._fragment.create();
|
||||
`}
|
||||
this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}( options.target, null );
|
||||
|
@ -230,4 +230,23 @@ describe("runtime", () => {
|
||||
new SvelteComponent();
|
||||
}, /'target' is a required option/);
|
||||
});
|
||||
|
||||
it("fails if options.hydrate is true but the component is non-hydratable", () => {
|
||||
const { code } = svelte.compile(`<div></div>`, {
|
||||
format: "iife",
|
||||
name: "SvelteComponent",
|
||||
dev: true
|
||||
});
|
||||
|
||||
const SvelteComponent = eval(
|
||||
`(function () { ${code}; return SvelteComponent; }())`
|
||||
);
|
||||
|
||||
assert.throws(() => {
|
||||
new SvelteComponent({
|
||||
target: {},
|
||||
hydrate: true
|
||||
});
|
||||
}, /options.hydrate only works if the component was compiled with the `hydratable: true` option/);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user