From 914529fa76e65c68003164c01bae4d391ead14fb Mon Sep 17 00:00:00 2001 From: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> Date: Tue, 20 Jun 2023 21:27:50 +0545 Subject: [PATCH] feat: smaller destructor chunk (#8763) technically a breaking change because someone with a mutation observer could rely on the order of operations --------- Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com> --- .changeset/eighty-tigers-rhyme.md | 5 + .../docs/05-misc/04-v4-migration-guide.md | 1 + .../src/compiler/compile/render_dom/Block.js | 22 ++++- .../action-custom-event-handler/expected.js | 5 +- .../svelte/test/js/samples/action/expected.js | 5 +- .../test/js/samples/bind-open/expected.js | 5 +- .../js/samples/bind-width-height/expected.js | 5 +- .../bindings-readonly-order/expected.js | 9 +- .../capture-inject-dev-only/expected.js | 9 +- .../samples/capture-inject-state/expected.js | 6 +- .../collapse-element-class-name/expected.js | 7 +- .../expected.js | 6 +- .../samples/component-static-var/expected.js | 9 +- .../expected.js | 4 +- .../expected.js | 9 +- .../js/samples/css-media-query/expected.js | 6 +- .../css-shadow-dom-keyframes/expected.js | 4 +- .../js/samples/custom-svelte-path/expected.js | 4 +- .../js/samples/data-attribute/expected.js | 8 +- .../test/js/samples/debug-empty/expected.js | 6 +- .../debug-foo-bar-baz-things/expected.js | 13 ++- .../test/js/samples/debug-foo/expected.js | 13 ++- .../samples/debug-no-dependencies/expected.js | 11 ++- .../samples/deconflict-builtins/expected.js | 9 +- .../expected.js | 4 +- .../samples/dom-preserve-comments/expected.js | 12 ++- .../samples/dont-invalidate-this/expected.js | 5 +- .../each-block-array-literal/expected.js | 9 +- .../each-block-changed-check/expected.js | 11 ++- .../each-block-keyed-animated/expected.js | 10 +- .../js/samples/each-block-keyed/expected.js | 10 +- .../samples/event-handler-dynamic/expected.js | 13 ++- .../event-handler-no-passive/expected.js | 5 +- .../js/samples/event-modifiers/expected.js | 5 +- .../test/js/samples/hoisted-const/expected.js | 4 +- .../test/js/samples/hoisted-let/expected.js | 4 +- .../samples/hydrated-void-element/expected.js | 10 +- .../hydrated-void-svg-element/expected.js | 6 +- .../js/samples/if-block-complex/expected.js | 9 +- .../js/samples/if-block-no-update/expected.js | 13 ++- .../js/samples/if-block-simple/expected.js | 9 +- .../test/js/samples/import-meta/expected.js | 8 +- .../js/samples/initial-context/expected.js | 5 +- .../expected.js | 4 +- .../inline-style-optimized-url/expected.js | 4 +- .../inline-style-optimized/expected.js | 4 +- .../inline-style-unoptimized/expected.js | 8 +- .../inline-style-without-updates/expected.js | 4 +- .../test/js/samples/input-files/expected.js | 5 +- .../input-no-initial-value/expected.js | 5 +- .../test/js/samples/input-range/expected.js | 5 +- .../test/js/samples/input-value/expected.js | 99 ++++++++++--------- .../input-without-blowback-guard/expected.js | 5 +- .../expected.js | 9 +- .../expected.js | 4 +- .../expected.js | 9 +- .../expected.js | 9 +- .../expected.js | 9 +- .../js/samples/legacy-input-type/expected.js | 4 +- .../test/js/samples/loop-protect/expected.js | 5 +- .../js/samples/media-bindings/expected.js | 7 +- .../natural-dimension-binding/expected.js | 13 ++- .../non-imported-component/expected.js | 5 +- .../samples/non-mutable-reference/expected.js | 4 +- .../js/samples/optional-chaining/expected.js | 25 ++--- .../reactive-class-optimized/expected.js | 36 +++---- .../samples/select-dynamic-value/expected.js | 4 +- .../expected.js | 6 +- .../src-attribute-check-in-svg/expected.js | 6 +- .../samples/src-attribute-check/expected.js | 10 +- .../svelte-element-event-handlers/expected.js | 5 +- .../samples/svelte-element-static/expected.js | 4 +- .../js/samples/svelte-element-svg/expected.js | 4 +- .../js/samples/svelte-element/expected.js | 27 +++-- .../test/js/samples/svg-title/expected.js | 4 +- .../js/samples/transition-local/expected.js | 14 ++- .../transition-repeated-outro/expected.js | 10 +- .../samples/unchanged-expression/expected.js | 8 +- .../expected.js | 4 +- .../use-elements-as-anchors/expected.js | 29 ++++-- .../expected.js | 4 +- .../js/samples/video-bindings/expected.js | 7 +- .../samples/window-binding-scroll/expected.js | 5 +- 83 files changed, 523 insertions(+), 243 deletions(-) create mode 100644 .changeset/eighty-tigers-rhyme.md diff --git a/.changeset/eighty-tigers-rhyme.md b/.changeset/eighty-tigers-rhyme.md new file mode 100644 index 0000000000..39501c159a --- /dev/null +++ b/.changeset/eighty-tigers-rhyme.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +feat: smaller minified output for destructor chunks diff --git a/documentation/docs/05-misc/04-v4-migration-guide.md b/documentation/docs/05-misc/04-v4-migration-guide.md index edb14603e1..41d06e6500 100644 --- a/documentation/docs/05-misc/04-v4-migration-guide.md +++ b/documentation/docs/05-misc/04-v4-migration-guide.md @@ -154,3 +154,4 @@ The order in which preprocessors are applied has changed. Now, preprocessors are - people implementing their own stores from scratch using the `StartStopNotifier` interface (which is passed to the create function of `writable` etc) from `svelte/store` now need to pass an update function in addition to the set function. This has no effect on people using stores or creating stores using the existing Svelte stores. ([#6750](https://github.com/sveltejs/svelte/issues/6750)) - `derived` will now throw an error on falsy values instead of stores passed to it. ([#7947](https://github.com/sveltejs/svelte/issues/7947)) - type definitions for `svelte/internal` were removed to further discourage usage of those internal methods which are not public API. Most of these will likely change for Svelte 5 +- Removal of DOM nodes is now batched which slightly changes its order, which might affect the order of events fired if you're using a MutationObserver on these elements ([#8763](https://github.com/sveltejs/svelte/pull/8763)) diff --git a/packages/svelte/src/compiler/compile/render_dom/Block.js b/packages/svelte/src/compiler/compile/render_dom/Block.js index 92867e8b6a..7f0f37aa7d 100644 --- a/packages/svelte/src/compiler/compile/render_dom/Block.js +++ b/packages/svelte/src/compiler/compile/render_dom/Block.js @@ -1,6 +1,7 @@ import { b, x } from 'code-red'; import { is_head } from './wrappers/shared/is_head.js'; import { regex_double_quotes } from '../../utils/patterns.js'; +import { flatten } from '../../utils/flatten.js'; export default class Block { /** @@ -380,8 +381,27 @@ export default class Block { if (this.chunks.destroy.length === 0) { properties.destroy = noop; } else { + const dispose_elements = []; + // Coalesce if blocks with the same condition + const others = flatten(this.chunks.destroy).filter( + /** @param {import('estree').Node} node */ + (node) => { + if ( + node.type === 'IfStatement' && + node.test.type === 'Identifier' && + node.test.name === 'detaching' + ) { + dispose_elements.push(node.consequent); + return false; + } else { + return true; + } + } + ); + properties.destroy = x`function #destroy(detaching) { - ${this.chunks.destroy} + ${dispose_elements.length ? b`if (detaching) { ${dispose_elements} }` : null} + ${others} }`; } if (!this.renderer.component.compile_options.dev) { diff --git a/packages/svelte/test/js/samples/action-custom-event-handler/expected.js b/packages/svelte/test/js/samples/action-custom-event-handler/expected.js index 6433d5b04a..aef87ecd16 100644 --- a/packages/svelte/test/js/samples/action-custom-event-handler/expected.js +++ b/packages/svelte/test/js/samples/action-custom-event-handler/expected.js @@ -36,7 +36,10 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(button); + if (detaching) { + detach(button); + } + mounted = false; dispose(); } diff --git a/packages/svelte/test/js/samples/action/expected.js b/packages/svelte/test/js/samples/action/expected.js index 689669c5bc..01ac6aa3ac 100644 --- a/packages/svelte/test/js/samples/action/expected.js +++ b/packages/svelte/test/js/samples/action/expected.js @@ -35,7 +35,10 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(a); + if (detaching) { + detach(a); + } + mounted = false; dispose(); } diff --git a/packages/svelte/test/js/samples/bind-open/expected.js b/packages/svelte/test/js/samples/bind-open/expected.js index 669cb41405..a96d26c594 100644 --- a/packages/svelte/test/js/samples/bind-open/expected.js +++ b/packages/svelte/test/js/samples/bind-open/expected.js @@ -37,7 +37,10 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(details); + if (detaching) { + detach(details); + } + mounted = false; dispose(); } diff --git a/packages/svelte/test/js/samples/bind-width-height/expected.js b/packages/svelte/test/js/samples/bind-width-height/expected.js index 287c1b95b8..ca84a502c9 100644 --- a/packages/svelte/test/js/samples/bind-width-height/expected.js +++ b/packages/svelte/test/js/samples/bind-width-height/expected.js @@ -29,7 +29,10 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(div); + if (detaching) { + detach(div); + } + div_resize_listener(); } }; diff --git a/packages/svelte/test/js/samples/bindings-readonly-order/expected.js b/packages/svelte/test/js/samples/bindings-readonly-order/expected.js index ea83573ee3..2f2a779d93 100644 --- a/packages/svelte/test/js/samples/bindings-readonly-order/expected.js +++ b/packages/svelte/test/js/samples/bindings-readonly-order/expected.js @@ -46,9 +46,12 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(input0); - if (detaching) detach(t); - if (detaching) detach(input1); + if (detaching) { + detach(input0); + detach(t); + detach(input1); + } + mounted = false; run_all(dispose); } diff --git a/packages/svelte/test/js/samples/capture-inject-dev-only/expected.js b/packages/svelte/test/js/samples/capture-inject-dev-only/expected.js index a87693dd9e..84d340e757 100644 --- a/packages/svelte/test/js/samples/capture-inject-dev-only/expected.js +++ b/packages/svelte/test/js/samples/capture-inject-dev-only/expected.js @@ -52,9 +52,12 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(p); - if (detaching) detach(t1); - if (detaching) detach(input); + if (detaching) { + detach(p); + detach(t1); + detach(input); + } + mounted = false; dispose(); } diff --git a/packages/svelte/test/js/samples/capture-inject-state/expected.js b/packages/svelte/test/js/samples/capture-inject-state/expected.js index 41f9b966b0..0c081eaae9 100644 --- a/packages/svelte/test/js/samples/capture-inject-state/expected.js +++ b/packages/svelte/test/js/samples/capture-inject-state/expected.js @@ -75,7 +75,9 @@ function create_fragment(ctx) { i: noop, o: noop, d: function destroy(detaching) { - if (detaching) detach_dev(p); + if (detaching) { + detach_dev(p); + } } }; @@ -197,4 +199,4 @@ class Component extends SvelteComponentDev { } export default Component; -export { moduleLiveBinding, moduleConstantProps }; +export { moduleLiveBinding, moduleConstantProps }; \ No newline at end of file diff --git a/packages/svelte/test/js/samples/collapse-element-class-name/expected.js b/packages/svelte/test/js/samples/collapse-element-class-name/expected.js index a55affe76e..d137d8b612 100644 --- a/packages/svelte/test/js/samples/collapse-element-class-name/expected.js +++ b/packages/svelte/test/js/samples/collapse-element-class-name/expected.js @@ -81,8 +81,11 @@ function create_fragment(ctx) { current = false; }, d(detaching) { - if (detaching) detach(div); - if (detaching) detach(t); + if (detaching) { + detach(div); + detach(t); + } + destroy_component(component, detaching); } }; diff --git a/packages/svelte/test/js/samples/collapses-text-around-comments/expected.js b/packages/svelte/test/js/samples/collapses-text-around-comments/expected.js index 63a32bbf38..c3fad2c8bd 100644 --- a/packages/svelte/test/js/samples/collapses-text-around-comments/expected.js +++ b/packages/svelte/test/js/samples/collapses-text-around-comments/expected.js @@ -38,7 +38,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(p); + if (detaching) { + detach(p); + } } }; } @@ -60,4 +62,4 @@ class Component extends SvelteComponent { } } -export default Component; +export default Component; \ No newline at end of file diff --git a/packages/svelte/test/js/samples/component-static-var/expected.js b/packages/svelte/test/js/samples/component-static-var/expected.js index 9e481a25c3..e333fdb3c1 100644 --- a/packages/svelte/test/js/samples/component-static-var/expected.js +++ b/packages/svelte/test/js/samples/component-static-var/expected.js @@ -74,11 +74,14 @@ function create_fragment(ctx) { current = false; }, d(detaching) { + if (detaching) { + detach(t0); + detach(t1); + detach(input); + } + destroy_component(foo, detaching); - if (detaching) detach(t0); destroy_component(bar, detaching); - if (detaching) detach(t1); - if (detaching) detach(input); mounted = false; dispose(); } diff --git a/packages/svelte/test/js/samples/component-store-access-invalidate/expected.js b/packages/svelte/test/js/samples/component-store-access-invalidate/expected.js index 2742481aef..4b12c40600 100644 --- a/packages/svelte/test/js/samples/component-store-access-invalidate/expected.js +++ b/packages/svelte/test/js/samples/component-store-access-invalidate/expected.js @@ -34,7 +34,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(h1); + if (detaching) { + detach(h1); + } } }; } diff --git a/packages/svelte/test/js/samples/component-store-reassign-invalidate/expected.js b/packages/svelte/test/js/samples/component-store-reassign-invalidate/expected.js index 9047316cef..edff2112ec 100644 --- a/packages/svelte/test/js/samples/component-store-reassign-invalidate/expected.js +++ b/packages/svelte/test/js/samples/component-store-reassign-invalidate/expected.js @@ -50,9 +50,12 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(h1); - if (detaching) detach(t1); - if (detaching) detach(button); + if (detaching) { + detach(h1); + detach(t1); + detach(button); + } + mounted = false; dispose(); } diff --git a/packages/svelte/test/js/samples/css-media-query/expected.js b/packages/svelte/test/js/samples/css-media-query/expected.js index d743432206..49a9fafefa 100644 --- a/packages/svelte/test/js/samples/css-media-query/expected.js +++ b/packages/svelte/test/js/samples/css-media-query/expected.js @@ -30,7 +30,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(div); + if (detaching) { + detach(div); + } } }; } @@ -42,4 +44,4 @@ class Component extends SvelteComponent { } } -export default Component; +export default Component; \ No newline at end of file diff --git a/packages/svelte/test/js/samples/css-shadow-dom-keyframes/expected.js b/packages/svelte/test/js/samples/css-shadow-dom-keyframes/expected.js index 98f5120c9b..a37fe84f40 100644 --- a/packages/svelte/test/js/samples/css-shadow-dom-keyframes/expected.js +++ b/packages/svelte/test/js/samples/css-shadow-dom-keyframes/expected.js @@ -32,7 +32,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(div); + if (detaching) { + detach(div); + } } }; } diff --git a/packages/svelte/test/js/samples/custom-svelte-path/expected.js b/packages/svelte/test/js/samples/custom-svelte-path/expected.js index 3210f216d3..b95296ce04 100644 --- a/packages/svelte/test/js/samples/custom-svelte-path/expected.js +++ b/packages/svelte/test/js/samples/custom-svelte-path/expected.js @@ -39,7 +39,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(h1); + if (detaching) { + detach(h1); + } } }; } diff --git a/packages/svelte/test/js/samples/data-attribute/expected.js b/packages/svelte/test/js/samples/data-attribute/expected.js index 2b2f8870e4..b4302a8978 100644 --- a/packages/svelte/test/js/samples/data-attribute/expected.js +++ b/packages/svelte/test/js/samples/data-attribute/expected.js @@ -37,9 +37,11 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(div0); - if (detaching) detach(t); - if (detaching) detach(div1); + if (detaching) { + detach(div0); + detach(t); + detach(div1); + } } }; } diff --git a/packages/svelte/test/js/samples/debug-empty/expected.js b/packages/svelte/test/js/samples/debug-empty/expected.js index ee304591cb..01e1d463b3 100644 --- a/packages/svelte/test/js/samples/debug-empty/expected.js +++ b/packages/svelte/test/js/samples/debug-empty/expected.js @@ -52,8 +52,10 @@ function create_fragment(ctx) { i: noop, o: noop, d: function destroy(detaching) { - if (detaching) detach_dev(h1); - if (detaching) detach_dev(t3); + if (detaching) { + detach_dev(h1); + detach_dev(t3); + } } }; diff --git a/packages/svelte/test/js/samples/debug-foo-bar-baz-things/expected.js b/packages/svelte/test/js/samples/debug-foo-bar-baz-things/expected.js index 360df103e4..1398f0f50a 100644 --- a/packages/svelte/test/js/samples/debug-foo-bar-baz-things/expected.js +++ b/packages/svelte/test/js/samples/debug-foo-bar-baz-things/expected.js @@ -68,8 +68,10 @@ function create_each_block(ctx) { } }, d: function destroy(detaching) { - if (detaching) detach_dev(span); - if (detaching) detach_dev(t1); + if (detaching) { + detach_dev(span); + detach_dev(t1); + } } }; @@ -152,9 +154,12 @@ function create_fragment(ctx) { i: noop, o: noop, d: function destroy(detaching) { + if (detaching) { + detach_dev(t0); + detach_dev(p); + } + destroy_each(each_blocks, detaching); - if (detaching) detach_dev(t0); - if (detaching) detach_dev(p); } }; diff --git a/packages/svelte/test/js/samples/debug-foo/expected.js b/packages/svelte/test/js/samples/debug-foo/expected.js index e4925d9ef0..800c9c14bc 100644 --- a/packages/svelte/test/js/samples/debug-foo/expected.js +++ b/packages/svelte/test/js/samples/debug-foo/expected.js @@ -62,8 +62,10 @@ function create_each_block(ctx) { } }, d: function destroy(detaching) { - if (detaching) detach_dev(span); - if (detaching) detach_dev(t1); + if (detaching) { + detach_dev(span); + detach_dev(t1); + } } }; @@ -146,9 +148,12 @@ function create_fragment(ctx) { i: noop, o: noop, d: function destroy(detaching) { + if (detaching) { + detach_dev(t0); + detach_dev(p); + } + destroy_each(each_blocks, detaching); - if (detaching) detach_dev(t0); - if (detaching) detach_dev(p); } }; diff --git a/packages/svelte/test/js/samples/debug-no-dependencies/expected.js b/packages/svelte/test/js/samples/debug-no-dependencies/expected.js index 8e3ae1c43a..fb06e42e1c 100644 --- a/packages/svelte/test/js/samples/debug-no-dependencies/expected.js +++ b/packages/svelte/test/js/samples/debug-no-dependencies/expected.js @@ -47,8 +47,10 @@ function create_each_block(ctx) { }, p: noop, d: function destroy(detaching) { - if (detaching) detach_dev(t0); - if (detaching) detach_dev(t1); + if (detaching) { + detach_dev(t0); + detach_dev(t1); + } } }; @@ -119,8 +121,11 @@ function create_fragment(ctx) { i: noop, o: noop, d: function destroy(detaching) { + if (detaching) { + detach_dev(each_1_anchor); + } + destroy_each(each_blocks, detaching); - if (detaching) detach_dev(each_1_anchor); } }; diff --git a/packages/svelte/test/js/samples/deconflict-builtins/expected.js b/packages/svelte/test/js/samples/deconflict-builtins/expected.js index e61d466acf..7e09cfafec 100644 --- a/packages/svelte/test/js/samples/deconflict-builtins/expected.js +++ b/packages/svelte/test/js/samples/deconflict-builtins/expected.js @@ -40,7 +40,9 @@ function create_each_block(ctx) { if (dirty & /*createElement*/ 1 && t_value !== (t_value = /*node*/ ctx[1] + "")) set_data(t, t_value); }, d(detaching) { - if (detaching) detach(span); + if (detaching) { + detach(span); + } } }; } @@ -98,8 +100,11 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { + if (detaching) { + detach(each_1_anchor); + } + destroy_each(each_blocks, detaching); - if (detaching) detach(each_1_anchor); } }; } diff --git a/packages/svelte/test/js/samples/dev-warning-missing-data-computed/expected.js b/packages/svelte/test/js/samples/dev-warning-missing-data-computed/expected.js index a94cf7b5f2..6b664b8511 100644 --- a/packages/svelte/test/js/samples/dev-warning-missing-data-computed/expected.js +++ b/packages/svelte/test/js/samples/dev-warning-missing-data-computed/expected.js @@ -49,7 +49,9 @@ function create_fragment(ctx) { i: noop, o: noop, d: function destroy(detaching) { - if (detaching) detach_dev(p); + if (detaching) { + detach_dev(p); + } } }; diff --git a/packages/svelte/test/js/samples/dom-preserve-comments/expected.js b/packages/svelte/test/js/samples/dom-preserve-comments/expected.js index aa9f509263..5c8d2a0c86 100644 --- a/packages/svelte/test/js/samples/dom-preserve-comments/expected.js +++ b/packages/svelte/test/js/samples/dom-preserve-comments/expected.js @@ -39,11 +39,13 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(div0); - if (detaching) detach(t1); - if (detaching) detach(c); - if (detaching) detach(t2); - if (detaching) detach(div1); + if (detaching) { + detach(div0); + detach(t1); + detach(c); + detach(t2); + detach(div1); + } } }; } diff --git a/packages/svelte/test/js/samples/dont-invalidate-this/expected.js b/packages/svelte/test/js/samples/dont-invalidate-this/expected.js index 0b155373a1..df6f051725 100644 --- a/packages/svelte/test/js/samples/dont-invalidate-this/expected.js +++ b/packages/svelte/test/js/samples/dont-invalidate-this/expected.js @@ -31,7 +31,10 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(input); + if (detaching) { + detach(input); + } + mounted = false; dispose(); } diff --git a/packages/svelte/test/js/samples/each-block-array-literal/expected.js b/packages/svelte/test/js/samples/each-block-array-literal/expected.js index 6620abc0fa..21bd8b25c7 100644 --- a/packages/svelte/test/js/samples/each-block-array-literal/expected.js +++ b/packages/svelte/test/js/samples/each-block-array-literal/expected.js @@ -40,7 +40,9 @@ function create_each_block(ctx) { if (dirty & /*a, b, c, d, e*/ 31 && t_value !== (t_value = /*num*/ ctx[5] + "")) set_data(t, t_value); }, d(detaching) { - if (detaching) detach(span); + if (detaching) { + detach(span); + } } }; } @@ -96,8 +98,11 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { + if (detaching) { + detach(each_1_anchor); + } + destroy_each(each_blocks, detaching); - if (detaching) detach(each_1_anchor); } }; } diff --git a/packages/svelte/test/js/samples/each-block-changed-check/expected.js b/packages/svelte/test/js/samples/each-block-changed-check/expected.js index 6d03010c26..034dfdb2df 100644 --- a/packages/svelte/test/js/samples/each-block-changed-check/expected.js +++ b/packages/svelte/test/js/samples/each-block-changed-check/expected.js @@ -75,7 +75,9 @@ function create_each_block(ctx) { if (dirty & /*comments*/ 1 && raw_value !== (raw_value = /*comment*/ ctx[4].html + "")) html_tag.p(raw_value); }, d(detaching) { - if (detaching) detach(div); + if (detaching) { + detach(div); + } } }; } @@ -141,9 +143,12 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { + if (detaching) { + detach(t0); + detach(p); + } + destroy_each(each_blocks, detaching); - if (detaching) detach(t0); - if (detaching) detach(p); } }; } diff --git a/packages/svelte/test/js/samples/each-block-keyed-animated/expected.js b/packages/svelte/test/js/samples/each-block-keyed-animated/expected.js index d8aa7a7501..d03193ee8b 100644 --- a/packages/svelte/test/js/samples/each-block-keyed-animated/expected.js +++ b/packages/svelte/test/js/samples/each-block-keyed-animated/expected.js @@ -60,7 +60,9 @@ function create_each_block(key_1, ctx) { stop_animation = create_animation(div, rect, foo, {}); }, d(detaching) { - if (detaching) detach(div); + if (detaching) { + detach(div); + } } }; } @@ -106,11 +108,13 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { + if (detaching) { + detach(each_1_anchor); + } + for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].d(detaching); } - - if (detaching) detach(each_1_anchor); } }; } diff --git a/packages/svelte/test/js/samples/each-block-keyed/expected.js b/packages/svelte/test/js/samples/each-block-keyed/expected.js index 10c41ee159..b84e36d2e4 100644 --- a/packages/svelte/test/js/samples/each-block-keyed/expected.js +++ b/packages/svelte/test/js/samples/each-block-keyed/expected.js @@ -45,7 +45,9 @@ function create_each_block(key_1, ctx) { if (dirty & /*things*/ 1 && t_value !== (t_value = /*thing*/ ctx[1].name + "")) set_data(t, t_value); }, d(detaching) { - if (detaching) detach(div); + if (detaching) { + detach(div); + } } }; } @@ -89,11 +91,13 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { + if (detaching) { + detach(each_1_anchor); + } + for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].d(detaching); } - - if (detaching) detach(each_1_anchor); } }; } diff --git a/packages/svelte/test/js/samples/event-handler-dynamic/expected.js b/packages/svelte/test/js/samples/event-handler-dynamic/expected.js index dacdfe15ac..3f64dd5464 100644 --- a/packages/svelte/test/js/samples/event-handler-dynamic/expected.js +++ b/packages/svelte/test/js/samples/event-handler-dynamic/expected.js @@ -74,11 +74,14 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(p0); - if (detaching) detach(t3); - if (detaching) detach(p1); - if (detaching) detach(t5); - if (detaching) detach(button2); + if (detaching) { + detach(p0); + detach(t3); + detach(p1); + detach(t5); + detach(button2); + } + mounted = false; run_all(dispose); } diff --git a/packages/svelte/test/js/samples/event-handler-no-passive/expected.js b/packages/svelte/test/js/samples/event-handler-no-passive/expected.js index 4d4b910d4e..23ca19693b 100644 --- a/packages/svelte/test/js/samples/event-handler-no-passive/expected.js +++ b/packages/svelte/test/js/samples/event-handler-no-passive/expected.js @@ -34,7 +34,10 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(a); + if (detaching) { + detach(a); + } + mounted = false; dispose(); } diff --git a/packages/svelte/test/js/samples/event-modifiers/expected.js b/packages/svelte/test/js/samples/event-modifiers/expected.js index 5b75ff1192..2c6d760bdb 100644 --- a/packages/svelte/test/js/samples/event-modifiers/expected.js +++ b/packages/svelte/test/js/samples/event-modifiers/expected.js @@ -78,7 +78,10 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(div1); + if (detaching) { + detach(div1); + } + mounted = false; run_all(dispose); } diff --git a/packages/svelte/test/js/samples/hoisted-const/expected.js b/packages/svelte/test/js/samples/hoisted-const/expected.js index 2842b54751..33005b121d 100644 --- a/packages/svelte/test/js/samples/hoisted-const/expected.js +++ b/packages/svelte/test/js/samples/hoisted-const/expected.js @@ -24,7 +24,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(b); + if (detaching) { + detach(b); + } } }; } diff --git a/packages/svelte/test/js/samples/hoisted-let/expected.js b/packages/svelte/test/js/samples/hoisted-let/expected.js index 285b124118..34eb7408ff 100644 --- a/packages/svelte/test/js/samples/hoisted-let/expected.js +++ b/packages/svelte/test/js/samples/hoisted-let/expected.js @@ -24,7 +24,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(b); + if (detaching) { + detach(b); + } } }; } diff --git a/packages/svelte/test/js/samples/hydrated-void-element/expected.js b/packages/svelte/test/js/samples/hydrated-void-element/expected.js index e84b9ad58e..929ff437db 100644 --- a/packages/svelte/test/js/samples/hydrated-void-element/expected.js +++ b/packages/svelte/test/js/samples/hydrated-void-element/expected.js @@ -48,9 +48,11 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(img); - if (detaching) detach(t); - if (detaching) detach(div); + if (detaching) { + detach(img); + detach(t); + detach(div); + } } }; } @@ -62,4 +64,4 @@ class Component extends SvelteComponent { } } -export default Component; +export default Component; \ No newline at end of file diff --git a/packages/svelte/test/js/samples/hydrated-void-svg-element/expected.js b/packages/svelte/test/js/samples/hydrated-void-svg-element/expected.js index e3b525bcdd..b2343eb801 100644 --- a/packages/svelte/test/js/samples/hydrated-void-svg-element/expected.js +++ b/packages/svelte/test/js/samples/hydrated-void-svg-element/expected.js @@ -43,7 +43,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(svg); + if (detaching) { + detach(svg); + } } }; } @@ -55,4 +57,4 @@ class Component extends SvelteComponent { } } -export default Component; +export default Component; \ No newline at end of file diff --git a/packages/svelte/test/js/samples/if-block-complex/expected.js b/packages/svelte/test/js/samples/if-block-complex/expected.js index a8244de8b0..4cfac4b685 100644 --- a/packages/svelte/test/js/samples/if-block-complex/expected.js +++ b/packages/svelte/test/js/samples/if-block-complex/expected.js @@ -23,7 +23,9 @@ function create_if_block(ctx) { insert(target, div, anchor); }, d(detaching) { - if (detaching) detach(div); + if (detaching) { + detach(div); + } } }; } @@ -46,8 +48,11 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { + if (detaching) { + detach(if_block_anchor); + } + if (if_block) if_block.d(detaching); - if (detaching) detach(if_block_anchor); } }; } diff --git a/packages/svelte/test/js/samples/if-block-no-update/expected.js b/packages/svelte/test/js/samples/if-block-no-update/expected.js index 25f197eb1a..88feef0f68 100644 --- a/packages/svelte/test/js/samples/if-block-no-update/expected.js +++ b/packages/svelte/test/js/samples/if-block-no-update/expected.js @@ -22,7 +22,9 @@ function create_else_block(ctx) { insert(target, p, anchor); }, d(detaching) { - if (detaching) detach(p); + if (detaching) { + detach(p); + } } }; } @@ -40,7 +42,9 @@ function create_if_block(ctx) { insert(target, p, anchor); }, d(detaching) { - if (detaching) detach(p); + if (detaching) { + detach(p); + } } }; } @@ -79,8 +83,11 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { + if (detaching) { + detach(if_block_anchor); + } + if_block.d(detaching); - if (detaching) detach(if_block_anchor); } }; } diff --git a/packages/svelte/test/js/samples/if-block-simple/expected.js b/packages/svelte/test/js/samples/if-block-simple/expected.js index 6debe92c24..4eba8876f1 100644 --- a/packages/svelte/test/js/samples/if-block-simple/expected.js +++ b/packages/svelte/test/js/samples/if-block-simple/expected.js @@ -22,7 +22,9 @@ function create_if_block(ctx) { insert(target, p, anchor); }, d(detaching) { - if (detaching) detach(p); + if (detaching) { + detach(p); + } } }; } @@ -57,8 +59,11 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { + if (detaching) { + detach(if_block_anchor); + } + if (if_block) if_block.d(detaching); - if (detaching) detach(if_block_anchor); } }; } diff --git a/packages/svelte/test/js/samples/import-meta/expected.js b/packages/svelte/test/js/samples/import-meta/expected.js index ba77398321..12547e75f2 100644 --- a/packages/svelte/test/js/samples/import-meta/expected.js +++ b/packages/svelte/test/js/samples/import-meta/expected.js @@ -31,9 +31,11 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(t0); - if (detaching) detach(t1); - if (detaching) detach(t2); + if (detaching) { + detach(t0); + detach(t1); + detach(t2); + } } }; } diff --git a/packages/svelte/test/js/samples/initial-context/expected.js b/packages/svelte/test/js/samples/initial-context/expected.js index 592e2a709e..6573c56973 100644 --- a/packages/svelte/test/js/samples/initial-context/expected.js +++ b/packages/svelte/test/js/samples/initial-context/expected.js @@ -31,7 +31,10 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(button); + if (detaching) { + detach(button); + } + mounted = false; dispose(); } diff --git a/packages/svelte/test/js/samples/inline-style-optimized-multiple/expected.js b/packages/svelte/test/js/samples/inline-style-optimized-multiple/expected.js index 4e4dba16d5..78f29a0b36 100644 --- a/packages/svelte/test/js/samples/inline-style-optimized-multiple/expected.js +++ b/packages/svelte/test/js/samples/inline-style-optimized-multiple/expected.js @@ -34,7 +34,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(div); + if (detaching) { + detach(div); + } } }; } diff --git a/packages/svelte/test/js/samples/inline-style-optimized-url/expected.js b/packages/svelte/test/js/samples/inline-style-optimized-url/expected.js index a861e9dc7e..ef782344c1 100644 --- a/packages/svelte/test/js/samples/inline-style-optimized-url/expected.js +++ b/packages/svelte/test/js/samples/inline-style-optimized-url/expected.js @@ -29,7 +29,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(div); + if (detaching) { + detach(div); + } } }; } diff --git a/packages/svelte/test/js/samples/inline-style-optimized/expected.js b/packages/svelte/test/js/samples/inline-style-optimized/expected.js index ea4f39ab47..897e88d731 100644 --- a/packages/svelte/test/js/samples/inline-style-optimized/expected.js +++ b/packages/svelte/test/js/samples/inline-style-optimized/expected.js @@ -29,7 +29,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(div); + if (detaching) { + detach(div); + } } }; } diff --git a/packages/svelte/test/js/samples/inline-style-unoptimized/expected.js b/packages/svelte/test/js/samples/inline-style-unoptimized/expected.js index 2900fb6ce7..a286294d05 100644 --- a/packages/svelte/test/js/samples/inline-style-unoptimized/expected.js +++ b/packages/svelte/test/js/samples/inline-style-unoptimized/expected.js @@ -42,9 +42,11 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(div0); - if (detaching) detach(t); - if (detaching) detach(div1); + if (detaching) { + detach(div0); + detach(t); + detach(div1); + } } }; } diff --git a/packages/svelte/test/js/samples/inline-style-without-updates/expected.js b/packages/svelte/test/js/samples/inline-style-without-updates/expected.js index ebfffe902c..af903b724d 100644 --- a/packages/svelte/test/js/samples/inline-style-without-updates/expected.js +++ b/packages/svelte/test/js/samples/inline-style-without-updates/expected.js @@ -25,7 +25,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(div); + if (detaching) { + detach(div); + } } }; } diff --git a/packages/svelte/test/js/samples/input-files/expected.js b/packages/svelte/test/js/samples/input-files/expected.js index 42ddddbcb3..7fea845632 100644 --- a/packages/svelte/test/js/samples/input-files/expected.js +++ b/packages/svelte/test/js/samples/input-files/expected.js @@ -34,7 +34,10 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(input); + if (detaching) { + detach(input); + } + mounted = false; dispose(); } diff --git a/packages/svelte/test/js/samples/input-no-initial-value/expected.js b/packages/svelte/test/js/samples/input-no-initial-value/expected.js index a91a95bde2..1d61753ccd 100644 --- a/packages/svelte/test/js/samples/input-no-initial-value/expected.js +++ b/packages/svelte/test/js/samples/input-no-initial-value/expected.js @@ -57,7 +57,10 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(form); + if (detaching) { + detach(form); + } + mounted = false; run_all(dispose); } diff --git a/packages/svelte/test/js/samples/input-range/expected.js b/packages/svelte/test/js/samples/input-range/expected.js index 7ced4b176b..74cedd5f7a 100644 --- a/packages/svelte/test/js/samples/input-range/expected.js +++ b/packages/svelte/test/js/samples/input-range/expected.js @@ -45,7 +45,10 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(input); + if (detaching) { + detach(input); + } + mounted = false; run_all(dispose); } diff --git a/packages/svelte/test/js/samples/input-value/expected.js b/packages/svelte/test/js/samples/input-value/expected.js index 2f951c9ae1..0432b3f830 100644 --- a/packages/svelte/test/js/samples/input-value/expected.js +++ b/packages/svelte/test/js/samples/input-value/expected.js @@ -350,53 +350,56 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(input0); - if (detaching) detach(t0); - if (detaching) detach(input1); - if (detaching) detach(t1); - if (detaching) detach(input2); - if (detaching) detach(t2); - if (detaching) detach(input3); - if (detaching) detach(t3); - if (detaching) detach(input4); - if (detaching) detach(t4); - if (detaching) detach(input5); - if (detaching) detach(t5); - if (detaching) detach(input6); - if (detaching) detach(t6); - if (detaching) detach(input7); - if (detaching) detach(t7); - if (detaching) detach(input8); - if (detaching) detach(t8); - if (detaching) detach(input9); - if (detaching) detach(t9); - if (detaching) detach(input10); - if (detaching) detach(t10); - if (detaching) detach(input11); - if (detaching) detach(t11); - if (detaching) detach(input12); - if (detaching) detach(t12); - if (detaching) detach(input13); - if (detaching) detach(t13); - if (detaching) detach(input14); - if (detaching) detach(t14); - if (detaching) detach(input15); - if (detaching) detach(t15); - if (detaching) detach(input16); - if (detaching) detach(t16); - if (detaching) detach(input17); - if (detaching) detach(t17); - if (detaching) detach(input18); - if (detaching) detach(t18); - if (detaching) detach(input19); - if (detaching) detach(t19); - if (detaching) detach(input20); - if (detaching) detach(t20); - if (detaching) detach(input21); - if (detaching) detach(t21); - if (detaching) detach(input22); - if (detaching) detach(t22); - if (detaching) detach(h1); + if (detaching) { + detach(input0); + detach(t0); + detach(input1); + detach(t1); + detach(input2); + detach(t2); + detach(input3); + detach(t3); + detach(input4); + detach(t4); + detach(input5); + detach(t5); + detach(input6); + detach(t6); + detach(input7); + detach(t7); + detach(input8); + detach(t8); + detach(input9); + detach(t9); + detach(input10); + detach(t10); + detach(input11); + detach(t11); + detach(input12); + detach(t12); + detach(input13); + detach(t13); + detach(input14); + detach(t14); + detach(input15); + detach(t15); + detach(input16); + detach(t16); + detach(input17); + detach(t17); + detach(input18); + detach(t18); + detach(input19); + detach(t19); + detach(input20); + detach(t20); + detach(input21); + detach(t21); + detach(input22); + detach(t22); + detach(h1); + } + mounted = false; run_all(dispose); } @@ -420,4 +423,4 @@ class Component extends SvelteComponent { } } -export default Component; +export default Component; \ No newline at end of file diff --git a/packages/svelte/test/js/samples/input-without-blowback-guard/expected.js b/packages/svelte/test/js/samples/input-without-blowback-guard/expected.js index 007177bda5..cfd641b142 100644 --- a/packages/svelte/test/js/samples/input-without-blowback-guard/expected.js +++ b/packages/svelte/test/js/samples/input-without-blowback-guard/expected.js @@ -38,7 +38,10 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(input); + if (detaching) { + detach(input); + } + mounted = false; dispose(); } diff --git a/packages/svelte/test/js/samples/instrumentation-script-if-no-block/expected.js b/packages/svelte/test/js/samples/instrumentation-script-if-no-block/expected.js index 7f51c64550..afe69a61a8 100644 --- a/packages/svelte/test/js/samples/instrumentation-script-if-no-block/expected.js +++ b/packages/svelte/test/js/samples/instrumentation-script-if-no-block/expected.js @@ -50,9 +50,12 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(button); - if (detaching) detach(t1); - if (detaching) detach(p); + if (detaching) { + detach(button); + detach(t1); + detach(p); + } + mounted = false; dispose(); } diff --git a/packages/svelte/test/js/samples/instrumentation-script-main-block/expected.js b/packages/svelte/test/js/samples/instrumentation-script-main-block/expected.js index a471a50b37..a1b8fd564e 100644 --- a/packages/svelte/test/js/samples/instrumentation-script-main-block/expected.js +++ b/packages/svelte/test/js/samples/instrumentation-script-main-block/expected.js @@ -34,7 +34,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(p); + if (detaching) { + detach(p); + } } }; } diff --git a/packages/svelte/test/js/samples/instrumentation-script-x-equals-x/expected.js b/packages/svelte/test/js/samples/instrumentation-script-x-equals-x/expected.js index ea0d65acb9..0371b20a21 100644 --- a/packages/svelte/test/js/samples/instrumentation-script-x-equals-x/expected.js +++ b/packages/svelte/test/js/samples/instrumentation-script-x-equals-x/expected.js @@ -51,9 +51,12 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(button); - if (detaching) detach(t1); - if (detaching) detach(p); + if (detaching) { + detach(button); + detach(t1); + detach(p); + } + mounted = false; dispose(); } diff --git a/packages/svelte/test/js/samples/instrumentation-template-if-no-block/expected.js b/packages/svelte/test/js/samples/instrumentation-template-if-no-block/expected.js index 0c2713a9cc..ecfc51587f 100644 --- a/packages/svelte/test/js/samples/instrumentation-template-if-no-block/expected.js +++ b/packages/svelte/test/js/samples/instrumentation-template-if-no-block/expected.js @@ -50,9 +50,12 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(button); - if (detaching) detach(t1); - if (detaching) detach(p); + if (detaching) { + detach(button); + detach(t1); + detach(p); + } + mounted = false; dispose(); } diff --git a/packages/svelte/test/js/samples/instrumentation-template-x-equals-x/expected.js b/packages/svelte/test/js/samples/instrumentation-template-x-equals-x/expected.js index 55cd310661..1db5980475 100644 --- a/packages/svelte/test/js/samples/instrumentation-template-x-equals-x/expected.js +++ b/packages/svelte/test/js/samples/instrumentation-template-x-equals-x/expected.js @@ -51,9 +51,12 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(button); - if (detaching) detach(t1); - if (detaching) detach(p); + if (detaching) { + detach(button); + detach(t1); + detach(p); + } + mounted = false; dispose(); } diff --git a/packages/svelte/test/js/samples/legacy-input-type/expected.js b/packages/svelte/test/js/samples/legacy-input-type/expected.js index 2b76a48522..29ad6d136e 100644 --- a/packages/svelte/test/js/samples/legacy-input-type/expected.js +++ b/packages/svelte/test/js/samples/legacy-input-type/expected.js @@ -25,7 +25,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(input); + if (detaching) { + detach(input); + } } }; } diff --git a/packages/svelte/test/js/samples/loop-protect/expected.js b/packages/svelte/test/js/samples/loop-protect/expected.js index 04033d0d95..3e5d63d07e 100644 --- a/packages/svelte/test/js/samples/loop-protect/expected.js +++ b/packages/svelte/test/js/samples/loop-protect/expected.js @@ -37,7 +37,10 @@ function create_fragment(ctx) { i: noop, o: noop, d: function destroy(detaching) { - if (detaching) detach_dev(div); + if (detaching) { + detach_dev(div); + } + /*div_binding*/ ctx[1](null); } }; diff --git a/packages/svelte/test/js/samples/media-bindings/expected.js b/packages/svelte/test/js/samples/media-bindings/expected.js index 8320d92b2a..4a3ac4804d 100644 --- a/packages/svelte/test/js/samples/media-bindings/expected.js +++ b/packages/svelte/test/js/samples/media-bindings/expected.js @@ -108,7 +108,10 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(audio); + if (detaching) { + detach(audio); + } + mounted = false; run_all(dispose); } @@ -249,4 +252,4 @@ class Component extends SvelteComponent { } } -export default Component; +export default Component; \ No newline at end of file diff --git a/packages/svelte/test/js/samples/natural-dimension-binding/expected.js b/packages/svelte/test/js/samples/natural-dimension-binding/expected.js index 3920c61009..3435c8fb87 100644 --- a/packages/svelte/test/js/samples/natural-dimension-binding/expected.js +++ b/packages/svelte/test/js/samples/natural-dimension-binding/expected.js @@ -55,11 +55,14 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(img); - if (detaching) detach(t0); - if (detaching) detach(t1); - if (detaching) detach(t2); - if (detaching) detach(t3); + if (detaching) { + detach(img); + detach(t0); + detach(t1); + detach(t2); + detach(t3); + } + mounted = false; dispose(); } diff --git a/packages/svelte/test/js/samples/non-imported-component/expected.js b/packages/svelte/test/js/samples/non-imported-component/expected.js index e3f2760ce0..503e0a4d57 100644 --- a/packages/svelte/test/js/samples/non-imported-component/expected.js +++ b/packages/svelte/test/js/samples/non-imported-component/expected.js @@ -49,8 +49,11 @@ function create_fragment(ctx) { current = false; }, d(detaching) { + if (detaching) { + detach(t); + } + destroy_component(imported, detaching); - if (detaching) detach(t); destroy_component(nonimported, detaching); } }; diff --git a/packages/svelte/test/js/samples/non-mutable-reference/expected.js b/packages/svelte/test/js/samples/non-mutable-reference/expected.js index adc67b9bc4..f82949f79b 100644 --- a/packages/svelte/test/js/samples/non-mutable-reference/expected.js +++ b/packages/svelte/test/js/samples/non-mutable-reference/expected.js @@ -24,7 +24,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(h1); + if (detaching) { + detach(h1); + } } }; } diff --git a/packages/svelte/test/js/samples/optional-chaining/expected.js b/packages/svelte/test/js/samples/optional-chaining/expected.js index 57369ddb72..31fc2f6667 100644 --- a/packages/svelte/test/js/samples/optional-chaining/expected.js +++ b/packages/svelte/test/js/samples/optional-chaining/expected.js @@ -142,17 +142,20 @@ function create_fragment(ctx) { current = false; }, d(detaching) { - if (detaching) detach(t0); - if (detaching) detach(t1); - if (detaching) detach(t2); - if (detaching) detach(t3); - if (detaching) detach(t4); - if (detaching) detach(t5); - if (detaching) detach(t6); - if (detaching) detach(t7); - if (detaching) detach(t8); - if (detaching) detach(div); - if (detaching) detach(t9); + if (detaching) { + detach(t0); + detach(t1); + detach(t2); + detach(t3); + detach(t4); + detach(t5); + detach(t6); + detach(t7); + detach(t8); + detach(div); + detach(t9); + } + destroy_component(component, detaching); } }; diff --git a/packages/svelte/test/js/samples/reactive-class-optimized/expected.js b/packages/svelte/test/js/samples/reactive-class-optimized/expected.js index 1d0606ad60..65445b62a4 100644 --- a/packages/svelte/test/js/samples/reactive-class-optimized/expected.js +++ b/packages/svelte/test/js/samples/reactive-class-optimized/expected.js @@ -106,23 +106,25 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(div0); - if (detaching) detach(t0); - if (detaching) detach(div1); - if (detaching) detach(t1); - if (detaching) detach(div2); - if (detaching) detach(t2); - if (detaching) detach(div3); - if (detaching) detach(t3); - if (detaching) detach(div4); - if (detaching) detach(t4); - if (detaching) detach(div5); - if (detaching) detach(t5); - if (detaching) detach(div6); - if (detaching) detach(t6); - if (detaching) detach(div7); - if (detaching) detach(t7); - if (detaching) detach(div8); + if (detaching) { + detach(div0); + detach(t0); + detach(div1); + detach(t1); + detach(div2); + detach(t2); + detach(div3); + detach(t3); + detach(div4); + detach(t4); + detach(div5); + detach(t5); + detach(div6); + detach(t6); + detach(div7); + detach(t7); + detach(div8); + } } }; } diff --git a/packages/svelte/test/js/samples/select-dynamic-value/expected.js b/packages/svelte/test/js/samples/select-dynamic-value/expected.js index 1d0896d6e8..69b2f406a6 100644 --- a/packages/svelte/test/js/samples/select-dynamic-value/expected.js +++ b/packages/svelte/test/js/samples/select-dynamic-value/expected.js @@ -43,7 +43,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(select); + if (detaching) { + detach(select); + } } }; } diff --git a/packages/svelte/test/js/samples/src-attribute-check-in-foreign/expected.js b/packages/svelte/test/js/samples/src-attribute-check-in-foreign/expected.js index 2eb4c0713c..9512a12b9e 100644 --- a/packages/svelte/test/js/samples/src-attribute-check-in-foreign/expected.js +++ b/packages/svelte/test/js/samples/src-attribute-check-in-foreign/expected.js @@ -45,7 +45,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(svg); + if (detaching) { + detach(svg); + } } }; } @@ -67,4 +69,4 @@ class Component extends SvelteComponent { } } -export default Component; +export default Component; \ No newline at end of file diff --git a/packages/svelte/test/js/samples/src-attribute-check-in-svg/expected.js b/packages/svelte/test/js/samples/src-attribute-check-in-svg/expected.js index 551a23e50e..f57532730c 100644 --- a/packages/svelte/test/js/samples/src-attribute-check-in-svg/expected.js +++ b/packages/svelte/test/js/samples/src-attribute-check-in-svg/expected.js @@ -46,7 +46,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(svg); + if (detaching) { + detach(svg); + } } }; } @@ -68,4 +70,4 @@ class Component extends SvelteComponent { } } -export default Component; +export default Component; \ No newline at end of file diff --git a/packages/svelte/test/js/samples/src-attribute-check/expected.js b/packages/svelte/test/js/samples/src-attribute-check/expected.js index 10ff49bb81..25577bfdfa 100644 --- a/packages/svelte/test/js/samples/src-attribute-check/expected.js +++ b/packages/svelte/test/js/samples/src-attribute-check/expected.js @@ -57,9 +57,11 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(img0); - if (detaching) detach(t); - if (detaching) detach(img1); + if (detaching) { + detach(img0); + detach(t); + detach(img1); + } } }; } @@ -83,4 +85,4 @@ class Component extends SvelteComponent { } } -export default Component; +export default Component; \ No newline at end of file diff --git a/packages/svelte/test/js/samples/svelte-element-event-handlers/expected.js b/packages/svelte/test/js/samples/svelte-element-event-handlers/expected.js index 944a04f180..82d1112134 100644 --- a/packages/svelte/test/js/samples/svelte-element-event-handlers/expected.js +++ b/packages/svelte/test/js/samples/svelte-element-event-handlers/expected.js @@ -44,7 +44,10 @@ function create_dynamic_element(ctx) { }, p: noop, d(detaching) { - if (detaching) detach(svelte_element1); + if (detaching) { + detach(svelte_element1); + } + mounted = false; run_all(dispose); } diff --git a/packages/svelte/test/js/samples/svelte-element-static/expected.js b/packages/svelte/test/js/samples/svelte-element-static/expected.js index 68d895db3c..d73ea066d2 100644 --- a/packages/svelte/test/js/samples/svelte-element-static/expected.js +++ b/packages/svelte/test/js/samples/svelte-element-static/expected.js @@ -26,7 +26,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(a); + if (detaching) { + detach(a); + } } }; } diff --git a/packages/svelte/test/js/samples/svelte-element-svg/expected.js b/packages/svelte/test/js/samples/svelte-element-svg/expected.js index 550b55592d..c9bff043b1 100644 --- a/packages/svelte/test/js/samples/svelte-element-svg/expected.js +++ b/packages/svelte/test/js/samples/svelte-element-svg/expected.js @@ -28,7 +28,9 @@ function create_dynamic_element(ctx) { }, p: noop, d(detaching) { - if (detaching) detach(svelte_element1); + if (detaching) { + detach(svelte_element1); + } } }; } diff --git a/packages/svelte/test/js/samples/svelte-element/expected.js b/packages/svelte/test/js/samples/svelte-element/expected.js index ae26744a3a..d54451e1b5 100644 --- a/packages/svelte/test/js/samples/svelte-element/expected.js +++ b/packages/svelte/test/js/samples/svelte-element/expected.js @@ -29,7 +29,9 @@ function create_dynamic_element_3(ctx) { }, p: noop, d(detaching) { - if (detaching) detach(svelte_element); + if (detaching) { + detach(svelte_element); + } } }; } @@ -49,7 +51,9 @@ function create_dynamic_element_2(ctx) { }, p: noop, d(detaching) { - if (detaching) detach(svelte_element); + if (detaching) { + detach(svelte_element); + } } }; } @@ -82,7 +86,9 @@ function create_dynamic_element_1(ctx) { toggle_class(svelte_element, "foo", /*dynamic_value*/ ctx[0]); }, d(detaching) { - if (detaching) detach(svelte_element); + if (detaching) { + detach(svelte_element); + } } }; } @@ -115,7 +121,9 @@ function create_dynamic_element(ctx) { toggle_class(svelte_element, "foo", /*dynamic_value*/ ctx[0]); }, d(detaching) { - if (detaching) detach(svelte_element); + if (detaching) { + detach(svelte_element); + } } }; } @@ -207,13 +215,16 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { + if (detaching) { + detach(t0); + detach(t1); + detach(t2); + detach(svelte_element3_anchor); + } + if (svelte_element0) svelte_element0.d(detaching); - if (detaching) detach(t0); if (svelte_element1) svelte_element1.d(detaching); - if (detaching) detach(t1); if (svelte_element2) svelte_element2.d(detaching); - if (detaching) detach(t2); - if (detaching) detach(svelte_element3_anchor); if (svelte_element3) svelte_element3.d(detaching); } }; diff --git a/packages/svelte/test/js/samples/svg-title/expected.js b/packages/svelte/test/js/samples/svg-title/expected.js index cd7ae3b551..5e17b9653a 100644 --- a/packages/svelte/test/js/samples/svg-title/expected.js +++ b/packages/svelte/test/js/samples/svg-title/expected.js @@ -31,7 +31,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(svg); + if (detaching) { + detach(svg); + } } }; } diff --git a/packages/svelte/test/js/samples/transition-local/expected.js b/packages/svelte/test/js/samples/transition-local/expected.js index 1824ccb066..d8c092d888 100644 --- a/packages/svelte/test/js/samples/transition-local/expected.js +++ b/packages/svelte/test/js/samples/transition-local/expected.js @@ -44,8 +44,11 @@ function create_if_block(ctx) { } }, d(detaching) { + if (detaching) { + detach(if_block_anchor); + } + if (if_block) if_block.d(detaching); - if (detaching) detach(if_block_anchor); } }; } @@ -75,7 +78,9 @@ function create_if_block_1(ctx) { }, o: noop, d(detaching) { - if (detaching) detach(div); + if (detaching) { + detach(div); + } } }; } @@ -110,8 +115,11 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { + if (detaching) { + detach(if_block_anchor); + } + if (if_block) if_block.d(detaching); - if (detaching) detach(if_block_anchor); } }; } diff --git a/packages/svelte/test/js/samples/transition-repeated-outro/expected.js b/packages/svelte/test/js/samples/transition-repeated-outro/expected.js index a2cbedffea..44c82a8c51 100644 --- a/packages/svelte/test/js/samples/transition-repeated-outro/expected.js +++ b/packages/svelte/test/js/samples/transition-repeated-outro/expected.js @@ -40,7 +40,10 @@ function create_if_block(ctx) { current = false; }, d(detaching) { - if (detaching) detach(div); + if (detaching) { + detach(div); + } + if (detaching && div_outro) div_outro.end(); } }; @@ -93,8 +96,11 @@ function create_fragment(ctx) { current = false; }, d(detaching) { + if (detaching) { + detach(if_block_anchor); + } + if (if_block) if_block.d(detaching); - if (detaching) detach(if_block_anchor); } }; } diff --git a/packages/svelte/test/js/samples/unchanged-expression/expected.js b/packages/svelte/test/js/samples/unchanged-expression/expected.js index 8ede703cec..876cf2bb9c 100644 --- a/packages/svelte/test/js/samples/unchanged-expression/expected.js +++ b/packages/svelte/test/js/samples/unchanged-expression/expected.js @@ -62,9 +62,11 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(div0); - if (detaching) detach(t7); - if (detaching) detach(div1); + if (detaching) { + detach(div0); + detach(t7); + detach(div1); + } } }; } diff --git a/packages/svelte/test/js/samples/unreferenced-state-not-invalidated/expected.js b/packages/svelte/test/js/samples/unreferenced-state-not-invalidated/expected.js index 8c238a8397..0b095637c4 100644 --- a/packages/svelte/test/js/samples/unreferenced-state-not-invalidated/expected.js +++ b/packages/svelte/test/js/samples/unreferenced-state-not-invalidated/expected.js @@ -33,7 +33,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(p); + if (detaching) { + detach(p); + } } }; } diff --git a/packages/svelte/test/js/samples/use-elements-as-anchors/expected.js b/packages/svelte/test/js/samples/use-elements-as-anchors/expected.js index 8a45cb54c8..5038341c1c 100644 --- a/packages/svelte/test/js/samples/use-elements-as-anchors/expected.js +++ b/packages/svelte/test/js/samples/use-elements-as-anchors/expected.js @@ -24,7 +24,9 @@ function create_if_block_4(ctx) { insert(target, p, anchor); }, d(detaching) { - if (detaching) detach(p); + if (detaching) { + detach(p); + } } }; } @@ -42,7 +44,9 @@ function create_if_block_3(ctx) { insert(target, p, anchor); }, d(detaching) { - if (detaching) detach(p); + if (detaching) { + detach(p); + } } }; } @@ -60,7 +64,9 @@ function create_if_block_2(ctx) { insert(target, p, anchor); }, d(detaching) { - if (detaching) detach(p); + if (detaching) { + detach(p); + } } }; } @@ -78,7 +84,9 @@ function create_if_block_1(ctx) { insert(target, p, anchor); }, d(detaching) { - if (detaching) detach(p); + if (detaching) { + detach(p); + } } }; } @@ -96,7 +104,9 @@ function create_if_block(ctx) { insert(target, p, anchor); }, d(detaching) { - if (detaching) detach(p); + if (detaching) { + detach(p); + } } }; } @@ -224,14 +234,17 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(div); + if (detaching) { + detach(div); + detach(t7); + detach(if_block4_anchor); + } + if (if_block0) if_block0.d(); if (if_block1) if_block1.d(); if (if_block2) if_block2.d(); if (if_block3) if_block3.d(); - if (detaching) detach(t7); if (if_block4) if_block4.d(detaching); - if (detaching) detach(if_block4_anchor); } }; } diff --git a/packages/svelte/test/js/samples/valid-inner-html-for-static-element/expected.js b/packages/svelte/test/js/samples/valid-inner-html-for-static-element/expected.js index f1ced27ba4..83e14b8280 100644 --- a/packages/svelte/test/js/samples/valid-inner-html-for-static-element/expected.js +++ b/packages/svelte/test/js/samples/valid-inner-html-for-static-element/expected.js @@ -24,7 +24,9 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(div); + if (detaching) { + detach(div); + } } }; } diff --git a/packages/svelte/test/js/samples/video-bindings/expected.js b/packages/svelte/test/js/samples/video-bindings/expected.js index 4ef1c2f7d8..e1c09bd316 100644 --- a/packages/svelte/test/js/samples/video-bindings/expected.js +++ b/packages/svelte/test/js/samples/video-bindings/expected.js @@ -70,7 +70,10 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(video); + if (detaching) { + detach(video); + } + video_resize_listener(); mounted = false; run_all(dispose); @@ -142,4 +145,4 @@ class Component extends SvelteComponent { } } -export default Component; +export default Component; \ No newline at end of file diff --git a/packages/svelte/test/js/samples/window-binding-scroll/expected.js b/packages/svelte/test/js/samples/window-binding-scroll/expected.js index ae155d42bf..d989fb1868 100644 --- a/packages/svelte/test/js/samples/window-binding-scroll/expected.js +++ b/packages/svelte/test/js/samples/window-binding-scroll/expected.js @@ -64,7 +64,10 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(p); + if (detaching) { + detach(p); + } + mounted = false; dispose(); }