diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index 2ffae2ee2f..046083ac8c 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -182,9 +182,7 @@ export default function dom( // TODO deprecate component.teardown() builder.addBlock(deindent` function ${name} ( options ) { - options = options || {}; - ${options.dev && - `if ( !options.target && !options._root ) throw new Error( "'target' is a required option" );`} + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); ${generator.usesRefs && `this.refs = {};`} this._state = ${templateProperties.data ? `@assign( @template.data(), options.data )` diff --git a/test/js/samples/collapses-text-around-comments/expected-bundle.js b/test/js/samples/collapses-text-around-comments/expected-bundle.js index e52f943862..6f43916fc4 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -201,7 +201,7 @@ function create_main_fragment ( state, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = assign( template.data(), options.data ); this._observers = { diff --git a/test/js/samples/collapses-text-around-comments/expected.js b/test/js/samples/collapses-text-around-comments/expected.js index 5a3e3d52f6..f5950ceed4 100644 --- a/test/js/samples/collapses-text-around-comments/expected.js +++ b/test/js/samples/collapses-text-around-comments/expected.js @@ -53,7 +53,7 @@ function create_main_fragment ( state, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = assign( template.data(), options.data ); this._observers = { diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index 0da5cdf32c..bad6814862 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -154,7 +154,7 @@ function create_main_fragment ( state, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; recompute( this._state, this._state, {}, true ); diff --git a/test/js/samples/computed-collapsed-if/expected.js b/test/js/samples/computed-collapsed-if/expected.js index a17e730122..72c7af709f 100644 --- a/test/js/samples/computed-collapsed-if/expected.js +++ b/test/js/samples/computed-collapsed-if/expected.js @@ -30,7 +30,7 @@ function create_main_fragment ( state, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; recompute( this._state, this._state, {}, true ); diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js index 3324ebf9be..068655d2c2 100644 --- a/test/js/samples/css-media-query/expected-bundle.js +++ b/test/js/samples/css-media-query/expected-bundle.js @@ -181,7 +181,7 @@ function create_main_fragment ( state, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; this._observers = { diff --git a/test/js/samples/css-media-query/expected.js b/test/js/samples/css-media-query/expected.js index 72338bb55b..92610d55db 100644 --- a/test/js/samples/css-media-query/expected.js +++ b/test/js/samples/css-media-query/expected.js @@ -37,7 +37,7 @@ function create_main_fragment ( state, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; this._observers = { diff --git a/test/js/samples/each-block-changed-check/expected-bundle.js b/test/js/samples/each-block-changed-check/expected-bundle.js index aac78b9adb..64dec50947 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -301,7 +301,7 @@ function create_each_block ( state, each_block_value, comment, i, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; this._observers = { diff --git a/test/js/samples/each-block-changed-check/expected.js b/test/js/samples/each-block-changed-check/expected.js index e7683e0743..fc17aac646 100644 --- a/test/js/samples/each-block-changed-check/expected.js +++ b/test/js/samples/each-block-changed-check/expected.js @@ -144,7 +144,7 @@ function create_each_block ( state, each_block_value, comment, i, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; this._observers = { diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index ed200a7b4c..5c7dd30034 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -192,7 +192,7 @@ function create_main_fragment ( state, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; this._observers = { diff --git a/test/js/samples/event-handlers-custom/expected.js b/test/js/samples/event-handlers-custom/expected.js index 9d5e771bdd..9a699ed073 100644 --- a/test/js/samples/event-handlers-custom/expected.js +++ b/test/js/samples/event-handlers-custom/expected.js @@ -48,7 +48,7 @@ function create_main_fragment ( state, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; this._observers = { diff --git a/test/js/samples/if-block-no-update/expected-bundle.js b/test/js/samples/if-block-no-update/expected-bundle.js index 273ce81fc1..fc22b073b7 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -236,7 +236,7 @@ function select_block_type ( state ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; this._observers = { diff --git a/test/js/samples/if-block-no-update/expected.js b/test/js/samples/if-block-no-update/expected.js index 8d30b66a03..f005d6d99b 100644 --- a/test/js/samples/if-block-no-update/expected.js +++ b/test/js/samples/if-block-no-update/expected.js @@ -88,7 +88,7 @@ function select_block_type ( state ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; this._observers = { diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js index 3b57117283..c55f23bd58 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -212,7 +212,7 @@ function create_if_block ( state, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; this._observers = { diff --git a/test/js/samples/if-block-simple/expected.js b/test/js/samples/if-block-simple/expected.js index db04589093..e91e84a0f4 100644 --- a/test/js/samples/if-block-simple/expected.js +++ b/test/js/samples/if-block-simple/expected.js @@ -64,7 +64,7 @@ function create_if_block ( state, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; this._observers = { diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index b40f56d109..c58837840a 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -184,7 +184,7 @@ function create_main_fragment ( state, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; this._observers = { diff --git a/test/js/samples/non-imported-component/expected.js b/test/js/samples/non-imported-component/expected.js index 2382e04ab3..05f02e52fe 100644 --- a/test/js/samples/non-imported-component/expected.js +++ b/test/js/samples/non-imported-component/expected.js @@ -48,7 +48,7 @@ function create_main_fragment ( state, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; this._observers = { diff --git a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js index a754118158..d8e99521c9 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js @@ -146,7 +146,7 @@ function create_main_fragment ( state, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; this._observers = { diff --git a/test/js/samples/onrender-onteardown-rewritten/expected.js b/test/js/samples/onrender-onteardown-rewritten/expected.js index bd473fc2d7..acc2cec5ce 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected.js @@ -22,7 +22,7 @@ function create_main_fragment ( state, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; this._observers = { diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js index 006152cea5..0286c91e9a 100644 --- a/test/js/samples/setup-method/expected-bundle.js +++ b/test/js/samples/setup-method/expected-bundle.js @@ -157,7 +157,7 @@ function create_main_fragment ( state, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; this._observers = { diff --git a/test/js/samples/setup-method/expected.js b/test/js/samples/setup-method/expected.js index 85f0d5c393..ae144507df 100644 --- a/test/js/samples/setup-method/expected.js +++ b/test/js/samples/setup-method/expected.js @@ -33,7 +33,7 @@ function create_main_fragment ( state, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; this._observers = { diff --git a/test/js/samples/use-elements-as-anchors/expected-bundle.js b/test/js/samples/use-elements-as-anchors/expected-bundle.js index 502e08b22e..a064bb5a82 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -396,7 +396,7 @@ function create_if_block_4 ( state, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; this._observers = { diff --git a/test/js/samples/use-elements-as-anchors/expected.js b/test/js/samples/use-elements-as-anchors/expected.js index 3ed3f1e7db..4e7f19ee9f 100644 --- a/test/js/samples/use-elements-as-anchors/expected.js +++ b/test/js/samples/use-elements-as-anchors/expected.js @@ -248,7 +248,7 @@ function create_if_block_4 ( state, component ) { } function SvelteComponent ( options ) { - options = options || {}; + if ( !options || ( !options.target && !options._root ) ) throw new Error( "'target' is a required option" ); this._state = options.data || {}; this._observers = { diff --git a/test/runtime/index.js b/test/runtime/index.js index ce30be761b..cbe5785b6d 100644 --- a/test/runtime/index.js +++ b/test/runtime/index.js @@ -215,8 +215,7 @@ describe("runtime", () => { it("fails if options.target is missing in dev mode", () => { const { code } = svelte.compile(`
`, { format: "iife", - name: "SvelteComponent", - dev: true + name: "SvelteComponent" }); const SvelteComponent = eval( diff --git a/test/runtime/samples/pass-no-options/_config.js b/test/runtime/samples/pass-no-options/_config.js deleted file mode 100644 index 9683944f21..0000000000 --- a/test/runtime/samples/pass-no-options/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -export default { - html: '