From 0b438c72b4b9260ef92f52c3f39422c6b3dc7725 Mon Sep 17 00:00:00 2001 From: bluwy Date: Mon, 6 Dec 2021 14:57:16 +0800 Subject: [PATCH] fix: better message --- src/runtime/internal/dev.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/runtime/internal/dev.ts b/src/runtime/internal/dev.ts index 4ed9f07871..c851267bef 100644 --- a/src/runtime/internal/dev.ts +++ b/src/runtime/internal/dev.ts @@ -152,16 +152,14 @@ export class SvelteComponentDev extends SvelteComponent { $$slot_def: any; constructor(options: IComponentOptions) { - // Ensure target is specified unless it is created inlined. - // Also ensure current_component is not null as it would be used as the component parent. - // It could be null if the Svelte instance isn't deduped, which target is then required. - if ( - !options || - (!options.target && (!options.$$inline || !current_component)) - ) { + if (!options || (!options.target && !options.$$inline)) { throw new Error("'target' is a required option"); } + if (!options.target && !current_component) { + throw new Error("Multiple Svelte instances detected. Please ensure only one instance exists, or set the 'target' option"); + } + super(); }