From 82c9217e534fef018b04dbfa0bf7483303f3dcb8 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 5 May 2018 16:36:18 -0400 Subject: [PATCH 1/3] do unmount work in destroy method --- src/compile/dom/Block.ts | 18 ++++----------- src/compile/dom/index.ts | 6 +---- src/compile/nodes/AwaitBlock.ts | 6 +---- src/compile/nodes/Component.ts | 8 ++----- src/compile/nodes/EachBlock.ts | 34 ++++++----------------------- src/compile/nodes/Element.ts | 6 ++--- src/compile/nodes/IfBlock.ts | 26 +++++++--------------- src/compile/nodes/RawMustacheTag.ts | 2 +- src/shared/await-block.js | 6 ++--- src/shared/dom.js | 4 ++-- src/shared/index.js | 9 +------- src/shared/keyed-each.js | 3 +-- 12 files changed, 33 insertions(+), 95 deletions(-) diff --git a/src/compile/dom/Block.ts b/src/compile/dom/Block.ts index 1725e598c74e..d2193bc1b13c 100644 --- a/src/compile/dom/Block.ts +++ b/src/compile/dom/Block.ts @@ -111,10 +111,10 @@ export default class Block { if (parentNode) { this.builders.mount.addLine(`@appendNode(${name}, ${parentNode});`); - if (parentNode === 'document.head') this.builders.unmount.addLine(`@detachNode(${name});`); + if (parentNode === 'document.head') this.builders.destroy.addLine(`@detachNode(${name});`); } else { this.builders.mount.addLine(`@insertNode(${name}, #target, anchor);`); - this.builders.unmount.addLine(`@detachNode(${name});`); + this.builders.destroy.addConditional('detach', `@detachNode(${name});`); } } @@ -162,7 +162,7 @@ export default class Block { } // minor hack – we need to ensure that any {{{triples}}} are detached first - this.builders.unmount.addBlockAtStart(this.builders.detachRaw.toString()); + this.builders.destroy.addBlockAtStart(this.builders.detachRaw.toString()); const properties = new CodeBuilder(); @@ -280,21 +280,11 @@ export default class Block { } } - if (this.builders.unmount.isEmpty()) { - properties.addBlock(`u: @noop,`); - } else { - properties.addBlock(deindent` - ${dev ? 'u: function unmount' : 'u'}() { - ${this.builders.unmount} - }, - `); - } - if (this.builders.destroy.isEmpty()) { properties.addBlock(`d: @noop`); } else { properties.addBlock(deindent` - ${dev ? 'd: function destroy' : 'd'}() { + ${dev ? 'd: function destroy' : 'd'}(detach) { ${this.builders.destroy} } `); diff --git a/src/compile/dom/index.ts b/src/compile/dom/index.ts index e43d64e3f2c5..e9e27980bb80 100644 --- a/src/compile/dom/index.ts +++ b/src/compile/dom/index.ts @@ -124,7 +124,7 @@ export default function dom( ? `@proto` : deindent` { - ${['destroy', 'get', 'fire', 'on', 'set', '_set', '_mount', '_unmount', '_differs'] + ${['destroy', 'get', 'fire', 'on', 'set', '_set', '_mount', '_differs'] .map(n => `${n}: @${n}`) .join(',\n')} }`; @@ -304,10 +304,6 @@ export default function dom( @assign(${name}.prototype, { _mount(target, anchor) { target.insertBefore(this, anchor); - }, - - _unmount() { - this.parentNode.removeChild(this); } }); diff --git a/src/compile/nodes/AwaitBlock.ts b/src/compile/nodes/AwaitBlock.ts index c03d6d475c01..26bad55cc982 100644 --- a/src/compile/nodes/AwaitBlock.ts +++ b/src/compile/nodes/AwaitBlock.ts @@ -167,12 +167,8 @@ export default class AwaitBlock extends Node { `); } - block.builders.unmount.addBlock(deindent` - ${info}.block.u(); - `); - block.builders.destroy.addBlock(deindent` - ${info}.block.d(); + ${info}.block.d(${parentNode ? '' : 'detach'}); ${info} = null; `); diff --git a/src/compile/nodes/Component.ts b/src/compile/nodes/Component.ts index 8c62d0d626a1..71c5f8082bfb 100644 --- a/src/compile/nodes/Component.ts +++ b/src/compile/nodes/Component.ts @@ -430,9 +430,7 @@ export default class Component extends Node { `); } - if (!parentNode) block.builders.unmount.addLine(`if (${name}) ${name}._unmount();`); - - block.builders.destroy.addLine(`if (${name}) ${name}.destroy(false);`); + block.builders.destroy.addLine(`if (${name}) ${name}.destroy(${parentNode ? '' : 'detach'});`); } else { const expression = this.name === 'svelte:self' ? compiler.name @@ -477,10 +475,8 @@ export default class Component extends Node { `); } - if (!parentNode) block.builders.unmount.addLine(`${name}._unmount();`); - block.builders.destroy.addLine(deindent` - ${name}.destroy(false); + ${name}.destroy(${parentNode ? '' : 'detach'}); ${this.ref && `if (#component.refs.${this.ref} === ${name}) #component.refs.${this.ref} = null;`} `); } diff --git a/src/compile/nodes/EachBlock.ts b/src/compile/nodes/EachBlock.ts index d9c93fc03692..0a789ed33974 100644 --- a/src/compile/nodes/EachBlock.ts +++ b/src/compile/nodes/EachBlock.ts @@ -213,8 +213,7 @@ export default class EachBlock extends Node { ${each_block_else}.c(); ${each_block_else}.${mountOrIntro}(${initialMountNode}, ${anchor}); } else if (${each_block_else}) { - ${each_block_else}.u(); - ${each_block_else}.d(); + ${each_block_else}.d(1); ${each_block_else} = null; } `); @@ -222,8 +221,7 @@ export default class EachBlock extends Node { block.builders.update.addBlock(deindent` if (${this.each_block_value}.${length}) { if (${each_block_else}) { - ${each_block_else}.u(); - ${each_block_else}.d(); + ${each_block_else}.d(1); ${each_block_else} = null; } } else if (!${each_block_else}) { @@ -234,12 +232,8 @@ export default class EachBlock extends Node { `); } - block.builders.unmount.addLine( - `if (${each_block_else}) ${each_block_else}.u()` - ); - block.builders.destroy.addBlock(deindent` - if (${each_block_else}) ${each_block_else}.d(); + if (${each_block_else}) ${each_block_else}.d(${parentNode ? '' : 'detach'}); `); } @@ -322,14 +316,8 @@ export default class EachBlock extends Node { ${blocks} = @updateKeyedEach(${blocks}, #component, changed, ${get_key}, ${dynamic ? '1' : '0'}, ctx, ${this.each_block_value}, ${lookup}, ${updateMountNode}, ${String(this.block.hasOutroMethod)}, ${create_each_block}, "${mountOrIntro}", ${anchor}, ${this.get_each_context}); `); - if (!parentNode) { - block.builders.unmount.addBlock(deindent` - for (#i = 0; #i < ${blocks}.length; #i += 1) ${blocks}[#i].u(); - `); - } - block.builders.destroy.addBlock(deindent` - for (#i = 0; #i < ${blocks}.length; #i += 1) ${blocks}[#i].d(); + for (#i = 0; #i < ${blocks}.length; #i += 1) ${blocks}[#i].d(${parentNode ? '' : 'detach'}); `); } @@ -424,8 +412,7 @@ export default class EachBlock extends Node { function ${outro}(i) { if (${iterations}[i]) { ${iterations}[i].o(function() { - ${iterations}[i].u(); - ${iterations}[i].d(); + ${iterations}[i].d(1); ${iterations}[i] = null; }); } @@ -435,8 +422,7 @@ export default class EachBlock extends Node { ` : deindent` for (; #i < ${iterations}.length; #i += 1) { - ${iterations}[#i].u(); - ${iterations}[#i].d(); + ${iterations}[#i].d(1); } ${iterations}.length = ${this.each_block_value}.${length}; `; @@ -456,13 +442,7 @@ export default class EachBlock extends Node { `); } - block.builders.unmount.addBlock(deindent` - for (var #i = 0; #i < ${iterations}.length; #i += 1) { - ${iterations}[#i].u(); - } - `); - - block.builders.destroy.addBlock(`@destroyEach(${iterations});`); + block.builders.destroy.addBlock(`@destroyEach(${iterations}, detach);`); } remount(name: string) { diff --git a/src/compile/nodes/Element.ts b/src/compile/nodes/Element.ts index 2dc46c69ad0d..dc1e5a271a2e 100644 --- a/src/compile/nodes/Element.ts +++ b/src/compile/nodes/Element.ts @@ -291,14 +291,14 @@ export default class Element extends Node { ); if (initialMountNode === 'document.head') { - block.builders.unmount.addLine(`@detachNode(${name});`); + block.builders.destroy.addLine(`@detachNode(${name});`); } } else { block.builders.mount.addLine(`@insertNode(${name}, #target, anchor);`); // TODO we eventually need to consider what happens to elements // that belong to the same outgroup as an outroing element... - block.builders.unmount.addLine(`@detachNode(${name});`); + block.builders.destroy.addConditional('detach', `@detachNode(${name});`); } // TODO move this into a class as well? @@ -503,7 +503,7 @@ export default class Element extends Node { `${resize_listener} = @addResizeListener(${this.var}, ${handler});` ); - block.builders.unmount.addLine( + block.builders.destroy.addLine( `${resize_listener}.cancel();` ); } else { diff --git a/src/compile/nodes/IfBlock.ts b/src/compile/nodes/IfBlock.ts index 6c89ed984854..56bee30538a4 100644 --- a/src/compile/nodes/IfBlock.ts +++ b/src/compile/nodes/IfBlock.ts @@ -192,13 +192,11 @@ export default class IfBlock extends Node { const changeBlock = deindent` ${hasElse ? deindent` - ${name}.u(); - ${name}.d(); + ${name}.d(1); ` : deindent` if (${name}) { - ${name}.u(); - ${name}.d(); + ${name}.d(1); }`} ${name} = ${current_block_type_and}${current_block_type}(#component, ctx); ${if_name}${name}.c(); @@ -221,9 +219,7 @@ export default class IfBlock extends Node { `); } - block.builders.unmount.addLine(`${if_name}${name}.u();`); - - block.builders.destroy.addLine(`${if_name}${name}.d();`); + block.builders.destroy.addLine(`${if_name}${name}.d(${parentNode ? '' : 'detach'});`); } // if any of the siblings have outros, we need to keep references to the blocks @@ -288,8 +284,7 @@ export default class IfBlock extends Node { const destroyOldBlock = deindent` ${name}.o(function() { - ${if_blocks}[ ${previous_block_index} ].u(); - ${if_blocks}[ ${previous_block_index} ].d(); + ${if_blocks}[ ${previous_block_index} ].d(1); ${if_blocks}[ ${previous_block_index} ] = null; }); `; @@ -343,8 +338,7 @@ export default class IfBlock extends Node { block.builders.destroy.addLine(deindent` ${if_current_block_type_index}{ - ${if_blocks}[${current_block_type_index}].u(); - ${if_blocks}[${current_block_type_index}].d(); + ${if_blocks}[${current_block_type_index}].d(${parentNode ? '' : 'detach'}); } `); } @@ -413,14 +407,12 @@ export default class IfBlock extends Node { const exit = branch.hasOutroMethod ? deindent` ${name}.o(function() { - ${name}.u(); - ${name}.d(); + ${name}.d(1); ${name} = null; }); ` : deindent` - ${name}.u(); - ${name}.d(); + ${name}.d(1); ${name} = null; `; @@ -432,9 +424,7 @@ export default class IfBlock extends Node { } `); - block.builders.unmount.addLine(`${if_name}${name}.u();`); - - block.builders.destroy.addLine(`${if_name}${name}.d();`); + block.builders.destroy.addLine(`${if_name}${name}.d(${parentNode ? '' : 'detach'});`); } getBranches( diff --git a/src/compile/nodes/RawMustacheTag.ts b/src/compile/nodes/RawMustacheTag.ts index cbb88129e578..5cfc4b50587a 100644 --- a/src/compile/nodes/RawMustacheTag.ts +++ b/src/compile/nodes/RawMustacheTag.ts @@ -76,7 +76,7 @@ export default class RawMustacheTag extends Tag { } block.builders.mount.addLine(insert(init)); - block.builders.detachRaw.addBlock(detach); + block.builders.detachRaw.addConditional('detach', detach); if (needsAnchorAfter && anchorBefore !== 'null') { // ...otherwise it should go afterwards diff --git a/src/shared/await-block.js b/src/shared/await-block.js index 4ef5536962cf..d58bb4a27edd 100644 --- a/src/shared/await-block.js +++ b/src/shared/await-block.js @@ -15,14 +15,12 @@ export function handlePromise(promise, info) { if (info.blocks) { info.blocks.forEach((block, i) => { if (i !== index && block) block.o(() => { - block.u(); - block.d(); + block.d(1); info.blocks[i] = null; }); }); } else { - info.block.u(); - info.block.d(); + info.block.d(1); } block.c(); diff --git a/src/shared/dom.js b/src/shared/dom.js index 2490fe0be83d..87ca9d6070ad 100644 --- a/src/shared/dom.js +++ b/src/shared/dom.js @@ -47,9 +47,9 @@ export function reinsertBefore(after, target) { while (parent.firstChild !== after) target.appendChild(parent.firstChild); } -export function destroyEach(iterations) { +export function destroyEach(iterations, detach) { for (var i = 0; i < iterations.length; i += 1) { - if (iterations[i]) iterations[i].d(); + if (iterations[i]) iterations[i].d(detach); } } diff --git a/src/shared/index.js b/src/shared/index.js index a2b1ba357647..cf82282ad809 100644 --- a/src/shared/index.js +++ b/src/shared/index.js @@ -17,8 +17,7 @@ export function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -133,10 +132,6 @@ export function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -export function _unmount() { - if (this._fragment) this._fragment.u(); -} - export var PENDING = {}; export var SUCCESS = {}; export var FAILURE = {}; @@ -154,7 +149,6 @@ export var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -167,6 +161,5 @@ export var protoDev = { _recompute: noop, _set, _mount, - _unmount, _differs }; diff --git a/src/shared/keyed-each.js b/src/shared/keyed-each.js index 8921b6fed50f..dac16930ee08 100644 --- a/src/shared/keyed-each.js +++ b/src/shared/keyed-each.js @@ -1,6 +1,5 @@ export function destroyBlock(block, lookup) { - block.u(); - block.d(); + block.d(1); lookup[block.key] = null; } From 103f278cfcaeeca87448428dc9ffd77f2db7b124 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 5 May 2018 16:48:49 -0400 Subject: [PATCH 2/3] update tests --- src/compile/dom/Block.ts | 5 +- src/compile/nodes/Slot.ts | 14 ++- test/cli/samples/basic/expected/Main.js | 20 ++-- .../samples/custom-element/expected/Main.js | 24 ++--- test/cli/samples/dev/expected/Main.js | 20 ++-- .../samples/dir-sourcemap/expected/Main.js | 18 +--- .../dir-sourcemap/expected/Main.js.map | 2 +- .../samples/dir-sourcemap/expected/Widget.js | 20 ++-- .../dir-sourcemap/expected/Widget.js.map | 2 +- test/cli/samples/dir-subdir/expected/Main.js | 18 +--- .../dir-subdir/expected/widget/Widget.js | 20 ++-- test/cli/samples/dir/expected/Main.js | 18 +--- test/cli/samples/dir/expected/Widget.js | 20 ++-- test/cli/samples/globals/expected/Main.js | 24 ++--- .../samples/sourcemap-inline/expected/Main.js | 22 ++--- test/cli/samples/sourcemap/expected/Main.js | 20 ++-- .../samples/sourcemap/expected/Main.js.map | 2 +- test/cli/samples/store/expected/Main.js | 24 ++--- test/js/samples/action/expected-bundle.js | 16 +-- test/js/samples/action/expected.js | 8 +- .../bind-width-height/expected-bundle.js | 19 ++-- test/js/samples/bind-width-height/expected.js | 11 ++- .../expected-bundle.js | 18 ++-- .../expected.js | 12 +-- .../component-static-array/expected-bundle.js | 16 +-- .../component-static-array/expected.js | 8 +- .../expected-bundle.js | 16 +-- .../component-static-immutable/expected.js | 8 +- .../expected-bundle.js | 16 +-- .../component-static-immutable2/expected.js | 8 +- .../component-static/expected-bundle.js | 16 +-- test/js/samples/component-static/expected.js | 8 +- .../computed-collapsed-if/expected-bundle.js | 10 +- .../samples/computed-collapsed-if/expected.js | 2 - .../css-media-query/expected-bundle.js | 18 ++-- test/js/samples/css-media-query/expected.js | 10 +- .../expected-bundle.js | 22 ++--- .../css-shadow-dom-keyframes/expected.js | 14 +-- .../deconflict-builtins/expected-bundle.js | 39 +++----- .../samples/deconflict-builtins/expected.js | 29 +++--- .../deconflict-globals/expected-bundle.js | 10 +- .../js/samples/deconflict-globals/expected.js | 2 - .../expected-bundle.js | 18 ++-- .../expected.js | 12 +-- .../samples/do-use-dataset/expected-bundle.js | 22 ++--- test/js/samples/do-use-dataset/expected.js | 16 +-- .../expected-bundle.js | 22 ++--- .../dont-use-dataset-in-legacy/expected.js | 16 +-- .../expected-bundle.js | 18 ++-- .../dont-use-dataset-in-svg/expected.js | 12 +-- .../expected-bundle.js | 44 ++++----- .../each-block-changed-check/expected.js | 34 +++---- .../event-handlers-custom/expected-bundle.js | 16 +-- .../samples/event-handlers-custom/expected.js | 8 +- .../head-no-whitespace/expected-bundle.js | 14 +-- .../js/samples/head-no-whitespace/expected.js | 6 +- .../if-block-no-update/expected-bundle.js | 43 ++++---- .../js/samples/if-block-no-update/expected.js | 37 ++++--- .../if-block-simple/expected-bundle.js | 33 +++---- test/js/samples/if-block-simple/expected.js | 27 +++--- .../expected-bundle.js | 18 ++-- .../expected.js | 12 +-- .../expected-bundle.js | 18 ++-- .../inline-style-optimized-url/expected.js | 12 +-- .../inline-style-optimized/expected-bundle.js | 18 ++-- .../inline-style-optimized/expected.js | 12 +-- .../expected-bundle.js | 22 ++--- .../inline-style-unoptimized/expected.js | 16 +-- .../expected-bundle.js | 16 +-- .../input-without-blowback-guard/expected.js | 8 +- .../legacy-input-type/expected-bundle.js | 18 ++-- test/js/samples/legacy-input-type/expected.js | 10 +- .../samples/media-bindings/expected-bundle.js | 16 +-- test/js/samples/media-bindings/expected.js | 8 +- .../non-imported-component/expected-bundle.js | 22 ++--- .../non-imported-component/expected.js | 14 ++- .../samples/setup-method/expected-bundle.js | 10 +- test/js/samples/setup-method/expected.js | 2 - test/js/samples/svg-title/expected-bundle.js | 18 ++-- test/js/samples/svg-title/expected.js | 10 +- test/js/samples/title/expected-bundle.js | 10 +- test/js/samples/title/expected.js | 2 - .../expected-bundle.js | 97 ++++++++----------- .../use-elements-as-anchors/expected.js | 91 ++++++++--------- .../window-binding-scroll/expected-bundle.js | 18 ++-- .../samples/window-binding-scroll/expected.js | 10 +- .../samples/await-then-catch-if/main.html | 16 +-- 87 files changed, 576 insertions(+), 975 deletions(-) diff --git a/src/compile/dom/Block.ts b/src/compile/dom/Block.ts index d2193bc1b13c..c9010cf7022f 100644 --- a/src/compile/dom/Block.ts +++ b/src/compile/dom/Block.ts @@ -34,7 +34,6 @@ export default class Block { intro: CodeBuilder; update: CodeBuilder; outro: CodeBuilder; - unmount: CodeBuilder; detachRaw: CodeBuilder; destroy: CodeBuilder; }; @@ -73,7 +72,6 @@ export default class Block { intro: new CodeBuilder(), update: new CodeBuilder(), outro: new CodeBuilder(), - unmount: new CodeBuilder(), detachRaw: new CodeBuilder(), destroy: new CodeBuilder(), }; @@ -161,7 +159,8 @@ export default class Block { this.builders.mount.addLine(`${this.autofocus}.focus();`); } - // minor hack – we need to ensure that any {{{triples}}} are detached first + // minor hack – we need to ensure that any {@html x} blocks are detached first + // (TODO: is this still necessary? or is there a neater approach?) this.builders.destroy.addBlockAtStart(this.builders.detachRaw.toString()); const properties = new CodeBuilder(); diff --git a/src/compile/nodes/Slot.ts b/src/compile/nodes/Slot.ts index 8515f3728a1f..7e55b020555d 100644 --- a/src/compile/nodes/Slot.ts +++ b/src/compile/nodes/Slot.ts @@ -55,13 +55,12 @@ export default class Slot extends Element { if (needsAnchorAfter) block.addVariable(anchorAfter); let mountBefore = block.builders.mount.toString(); - let unmountBefore = block.builders.unmount.toString(); + let destroyBefore = block.builders.destroy.toString(); block.builders.create.pushCondition(`!${content_name}`); block.builders.hydrate.pushCondition(`!${content_name}`); block.builders.mount.pushCondition(`!${content_name}`); block.builders.update.pushCondition(`!${content_name}`); - block.builders.unmount.pushCondition(`!${content_name}`); block.builders.destroy.pushCondition(`!${content_name}`); this.children.forEach((child: Node) => { @@ -72,7 +71,6 @@ export default class Slot extends Element { block.builders.hydrate.popCondition(); block.builders.mount.popCondition(); block.builders.update.popCondition(); - block.builders.unmount.popCondition(); block.builders.destroy.popCondition(); const mountLeadin = block.builders.mount.toString() !== mountBefore @@ -101,30 +99,30 @@ export default class Slot extends Element { // so that it can be reinserted later // TODO so that this can work with public API, component._slotted should // be all fragments, derived from options.slots. Not === options.slots - const unmountLeadin = block.builders.unmount.toString() !== unmountBefore + const unmountLeadin = block.builders.destroy.toString() !== destroyBefore ? `else` : `if (${content_name})`; if (anchorBefore === 'null' && anchorAfter === 'null') { - block.builders.unmount.addBlock(deindent` + block.builders.destroy.addBlock(deindent` ${unmountLeadin} { @reinsertChildren(${parentNode}, ${content_name}); } `); } else if (anchorBefore === 'null') { - block.builders.unmount.addBlock(deindent` + block.builders.destroy.addBlock(deindent` ${unmountLeadin} { @reinsertBefore(${anchorAfter}, ${content_name}); } `); } else if (anchorAfter === 'null') { - block.builders.unmount.addBlock(deindent` + block.builders.destroy.addBlock(deindent` ${unmountLeadin} { @reinsertAfter(${anchorBefore}, ${content_name}); } `); } else { - block.builders.unmount.addBlock(deindent` + block.builders.destroy.addBlock(deindent` ${unmountLeadin} { @reinsertBetween(${anchorBefore}, ${anchorAfter}, ${content_name}); @detachNode(${anchorBefore}); diff --git a/test/cli/samples/basic/expected/Main.js b/test/cli/samples/basic/expected/Main.js index 6514bbbd3157..dce010fb4c4c 100644 --- a/test/cli/samples/basic/expected/Main.js +++ b/test/cli/samples/basic/expected/Main.js @@ -1,4 +1,4 @@ -/* src/Main.html generated by Svelte v2.3.0 */ +/* src/Main.html generated by Svelte v2.4.4 */ function create_main_fragment(component, ctx) { var p; @@ -15,11 +15,11 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -43,7 +43,6 @@ assign(Main.prototype, { set: set, _set: _set, _mount: _mount, - _unmount: _unmount, _differs: _differs }); @@ -82,8 +81,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -155,10 +153,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - function _differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } diff --git a/test/cli/samples/custom-element/expected/Main.js b/test/cli/samples/custom-element/expected/Main.js index e92ada81cdb1..d1b96c98992b 100644 --- a/test/cli/samples/custom-element/expected/Main.js +++ b/test/cli/samples/custom-element/expected/Main.js @@ -1,4 +1,4 @@ -/* src/Main.html generated by Svelte v2.3.0 */ +/* src/Main.html generated by Svelte v2.4.4 */ function create_main_fragment(component, ctx) { var p; @@ -16,11 +16,11 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -57,16 +57,11 @@ assign(Main.prototype, { set: set, _set: _set, _mount: _mount, - _unmount: _unmount, _differs: _differs }); assign(Main.prototype, { _mount(target, anchor) { target.insertBefore(this, anchor); - }, - - _unmount() { - this.parentNode.removeChild(this); } }); @@ -107,8 +102,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -180,10 +174,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - function _differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } diff --git a/test/cli/samples/dev/expected/Main.js b/test/cli/samples/dev/expected/Main.js index 401307fe2eaf..a2da6346b646 100644 --- a/test/cli/samples/dev/expected/Main.js +++ b/test/cli/samples/dev/expected/Main.js @@ -1,4 +1,4 @@ -/* src/Main.html generated by Svelte v2.3.0 */ +/* src/Main.html generated by Svelte v2.4.4 */ function create_main_fragment(component, ctx) { var p; @@ -15,11 +15,11 @@ function create_main_fragment(component, ctx) { p: noop, - u: function unmount() { - detachNode(p); - }, - - d: noop + d: function destroy(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -46,7 +46,6 @@ assign(Main.prototype, { set: setDev, _set: _set, _mount: _mount, - _unmount: _unmount, _differs: _differs }); @@ -158,10 +157,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - function _differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } @@ -175,8 +170,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } diff --git a/test/cli/samples/dir-sourcemap/expected/Main.js b/test/cli/samples/dir-sourcemap/expected/Main.js index 7cdd41dd4a44..b4a005c0ac5f 100644 --- a/test/cli/samples/dir-sourcemap/expected/Main.js +++ b/test/cli/samples/dir-sourcemap/expected/Main.js @@ -1,4 +1,4 @@ -/* src/Main.html generated by Svelte v2.3.0 */ +/* src/Main.html generated by Svelte v2.4.4 */ import Widget from './Widget.html'; @@ -20,12 +20,8 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - widget._unmount(); - }, - - d() { - widget.destroy(false); + d(detach) { + widget.destroy(detach); } }; } @@ -62,7 +58,6 @@ assign(Main.prototype, { set: set, _set: _set, _mount: _mount, - _unmount: _unmount, _differs: _differs }); @@ -93,8 +88,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -166,10 +160,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - function _differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } diff --git a/test/cli/samples/dir-sourcemap/expected/Main.js.map b/test/cli/samples/dir-sourcemap/expected/Main.js.map index cf890d44355e..6e2eb7d0b0bd 100644 --- a/test/cli/samples/dir-sourcemap/expected/Main.js.map +++ b/test/cli/samples/dir-sourcemap/expected/Main.js.map @@ -1 +1 @@ -{"version":3,"file":"Main.js","sources":["../src/Main.html"],"sourcesContent":["\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"Main.js","sources":["../src/Main.html"],"sourcesContent":["\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/test/cli/samples/dir-sourcemap/expected/Widget.js b/test/cli/samples/dir-sourcemap/expected/Widget.js index ad16d7aef56f..28223fdd1c0e 100644 --- a/test/cli/samples/dir-sourcemap/expected/Widget.js +++ b/test/cli/samples/dir-sourcemap/expected/Widget.js @@ -1,4 +1,4 @@ -/* src/Widget.html generated by Svelte v2.3.0 */ +/* src/Widget.html generated by Svelte v2.4.4 */ function create_main_fragment(component, ctx) { var p; @@ -15,11 +15,11 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -43,7 +43,6 @@ assign(Widget.prototype, { set: set, _set: _set, _mount: _mount, - _unmount: _unmount, _differs: _differs }); @@ -82,8 +81,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -155,10 +153,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - function _differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } diff --git a/test/cli/samples/dir-sourcemap/expected/Widget.js.map b/test/cli/samples/dir-sourcemap/expected/Widget.js.map index d007680a8131..8d57bc3c9a19 100644 --- a/test/cli/samples/dir-sourcemap/expected/Widget.js.map +++ b/test/cli/samples/dir-sourcemap/expected/Widget.js.map @@ -1 +1 @@ -{"version":3,"file":"Widget.js","sources":["../src/Widget.html"],"sourcesContent":["

widget

"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"Widget.js","sources":["../src/Widget.html"],"sourcesContent":["

widget

"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/test/cli/samples/dir-subdir/expected/Main.js b/test/cli/samples/dir-subdir/expected/Main.js index 52c9caf09257..1a595e80dd4f 100644 --- a/test/cli/samples/dir-subdir/expected/Main.js +++ b/test/cli/samples/dir-subdir/expected/Main.js @@ -1,4 +1,4 @@ -/* src/Main.html generated by Svelte v2.3.0 */ +/* src/Main.html generated by Svelte v2.4.4 */ import Widget from './widget/Widget.html'; @@ -20,12 +20,8 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - widget._unmount(); - }, - - d() { - widget.destroy(false); + d(detach) { + widget.destroy(detach); } }; } @@ -62,7 +58,6 @@ assign(Main.prototype, { set: set, _set: _set, _mount: _mount, - _unmount: _unmount, _differs: _differs }); @@ -93,8 +88,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -166,10 +160,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - function _differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } diff --git a/test/cli/samples/dir-subdir/expected/widget/Widget.js b/test/cli/samples/dir-subdir/expected/widget/Widget.js index 66543c808ed8..7ab7e73f96c1 100644 --- a/test/cli/samples/dir-subdir/expected/widget/Widget.js +++ b/test/cli/samples/dir-subdir/expected/widget/Widget.js @@ -1,4 +1,4 @@ -/* src/widget/Widget.html generated by Svelte v2.3.0 */ +/* src/widget/Widget.html generated by Svelte v2.4.4 */ function create_main_fragment(component, ctx) { var p; @@ -15,11 +15,11 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -43,7 +43,6 @@ assign(Widget.prototype, { set: set, _set: _set, _mount: _mount, - _unmount: _unmount, _differs: _differs }); @@ -82,8 +81,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -155,10 +153,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - function _differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } diff --git a/test/cli/samples/dir/expected/Main.js b/test/cli/samples/dir/expected/Main.js index 77a56bf3bfb0..43ff753ecad4 100644 --- a/test/cli/samples/dir/expected/Main.js +++ b/test/cli/samples/dir/expected/Main.js @@ -1,4 +1,4 @@ -/* src/Main.html generated by Svelte v2.3.0 */ +/* src/Main.html generated by Svelte v2.4.4 */ import Widget from './Widget.html'; @@ -20,12 +20,8 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - widget._unmount(); - }, - - d() { - widget.destroy(false); + d(detach) { + widget.destroy(detach); } }; } @@ -62,7 +58,6 @@ assign(Main.prototype, { set: set, _set: _set, _mount: _mount, - _unmount: _unmount, _differs: _differs }); @@ -93,8 +88,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -166,10 +160,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - function _differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } diff --git a/test/cli/samples/dir/expected/Widget.js b/test/cli/samples/dir/expected/Widget.js index ecb3303e7d48..9c62194627df 100644 --- a/test/cli/samples/dir/expected/Widget.js +++ b/test/cli/samples/dir/expected/Widget.js @@ -1,4 +1,4 @@ -/* src/Widget.html generated by Svelte v2.3.0 */ +/* src/Widget.html generated by Svelte v2.4.4 */ function create_main_fragment(component, ctx) { var p; @@ -15,11 +15,11 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -43,7 +43,6 @@ assign(Widget.prototype, { set: set, _set: _set, _mount: _mount, - _unmount: _unmount, _differs: _differs }); @@ -82,8 +81,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -155,10 +153,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - function _differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } diff --git a/test/cli/samples/globals/expected/Main.js b/test/cli/samples/globals/expected/Main.js index 2db0a261a29b..968eb228fec7 100644 --- a/test/cli/samples/globals/expected/Main.js +++ b/test/cli/samples/globals/expected/Main.js @@ -1,4 +1,4 @@ -/* src/Main.html generated by Svelte v2.3.0 */ +/* src/Main.html generated by Svelte v2.4.4 */ var Main = (function(answer) { "use strict"; answer = (answer && answer.__esModule) ? answer["default"] : answer; @@ -30,11 +30,11 @@ var Main = (function(answer) { "use strict"; } }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -58,7 +58,6 @@ var Main = (function(answer) { "use strict"; set: set, _set: _set, _mount: _mount, - _unmount: _unmount, _differs: _differs }); @@ -84,8 +83,6 @@ var Main = (function(answer) { "use strict"; node.parentNode.removeChild(node); } - function noop() {} - function init(component, options) { component._handlers = blankObject(); component._bind = options._bind; @@ -105,8 +102,7 @@ var Main = (function(answer) { "use strict"; this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -178,14 +174,12 @@ var Main = (function(answer) { "use strict"; this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } - function _unmount() { - if (this._fragment) this._fragment.u(); - } - function _differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } + function noop() {} + function blankObject() { return Object.create(null); } diff --git a/test/cli/samples/sourcemap-inline/expected/Main.js b/test/cli/samples/sourcemap-inline/expected/Main.js index fe639ac270cc..3da16e1a57e4 100644 --- a/test/cli/samples/sourcemap-inline/expected/Main.js +++ b/test/cli/samples/sourcemap-inline/expected/Main.js @@ -1,4 +1,4 @@ -/* src/Main.html generated by Svelte v2.3.0 */ +/* src/Main.html generated by Svelte v2.4.4 */ function create_main_fragment(component, ctx) { var p; @@ -15,11 +15,11 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -43,7 +43,6 @@ assign(Main.prototype, { set: set, _set: _set, _mount: _mount, - _unmount: _unmount, _differs: _differs }); @@ -82,8 +81,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -155,10 +153,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - function _differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } @@ -171,4 +165,4 @@ function callAll(fns) { while (fns && fns.length) fns.shift()(); } export default Main; -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWFpbi5qcyIsInNvdXJjZXMiOlsiLi4vc3JjL01haW4uaHRtbCJdLCJzb3VyY2VzQ29udGVudCI6WyI8cD5IZWxsbyB3b3JsZCE8L3A+XG5cbjxzY3JpcHQ+XG5cdGV4cG9ydCBkZWZhdWx0IHtcblx0XHRvbnJlbmRlciAoKSB7XG5cdFx0XHRjb25zb2xlLmxvZyggJ2hlcmUnICk7XG5cdFx0fVxuXHR9O1xuPC9zY3JpcHQ+Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0= +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWFpbi5qcyIsInNvdXJjZXMiOlsiLi4vc3JjL01haW4uaHRtbCJdLCJzb3VyY2VzQ29udGVudCI6WyI8cD5IZWxsbyB3b3JsZCE8L3A+XG5cbjxzY3JpcHQ+XG5cdGV4cG9ydCBkZWZhdWx0IHtcblx0XHRvbnJlbmRlciAoKSB7XG5cdFx0XHRjb25zb2xlLmxvZyggJ2hlcmUnICk7XG5cdFx0fVxuXHR9O1xuPC9zY3JpcHQ+Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0= diff --git a/test/cli/samples/sourcemap/expected/Main.js b/test/cli/samples/sourcemap/expected/Main.js index 4f303ce506ce..b44a4b2f2714 100644 --- a/test/cli/samples/sourcemap/expected/Main.js +++ b/test/cli/samples/sourcemap/expected/Main.js @@ -1,4 +1,4 @@ -/* src/Main.html generated by Svelte v2.3.0 */ +/* src/Main.html generated by Svelte v2.4.4 */ function create_main_fragment(component, ctx) { var p; @@ -15,11 +15,11 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -43,7 +43,6 @@ assign(Main.prototype, { set: set, _set: _set, _mount: _mount, - _unmount: _unmount, _differs: _differs }); @@ -82,8 +81,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -155,10 +153,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - function _differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } diff --git a/test/cli/samples/sourcemap/expected/Main.js.map b/test/cli/samples/sourcemap/expected/Main.js.map index 5133d81436ba..c8777bdd112e 100644 --- a/test/cli/samples/sourcemap/expected/Main.js.map +++ b/test/cli/samples/sourcemap/expected/Main.js.map @@ -1 +1 @@ -{"version":3,"file":"Main.js","sources":["../src/Main.html"],"sourcesContent":["

Hello world!

\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"Main.js","sources":["../src/Main.html"],"sourcesContent":["

Hello world!

\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/test/cli/samples/store/expected/Main.js b/test/cli/samples/store/expected/Main.js index 3588e6078997..320a159497ae 100644 --- a/test/cli/samples/store/expected/Main.js +++ b/test/cli/samples/store/expected/Main.js @@ -1,4 +1,4 @@ -/* src/Main.html generated by Svelte v2.3.0 */ +/* src/Main.html generated by Svelte v2.4.4 */ function create_main_fragment(component, ctx) { var h1, text, text_1; @@ -22,11 +22,11 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(h1); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(h1); + } + } }; } @@ -53,7 +53,6 @@ assign(Main.prototype, { set: set, _set: _set, _mount: _mount, - _unmount: _unmount, _differs: _differs }); @@ -79,8 +78,6 @@ function detachNode(node) { node.parentNode.removeChild(node); } -function noop() {} - function init(component, options) { component._handlers = blankObject(); component._bind = options._bind; @@ -104,8 +101,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -177,14 +173,12 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - function _differs(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } +function noop() {} + function blankObject() { return Object.create(null); } diff --git a/test/js/samples/action/expected-bundle.js b/test/js/samples/action/expected-bundle.js index 4814e2fede4c..49e0372582f3 100644 --- a/test/js/samples/action/expected-bundle.js +++ b/test/js/samples/action/expected-bundle.js @@ -26,8 +26,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -116,10 +115,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -129,7 +124,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -167,11 +161,11 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(a); - }, + d(detach) { + if (detach) { + detachNode(a); + } - d() { if (typeof link_action.destroy === 'function') link_action.destroy.call(component); } }; diff --git a/test/js/samples/action/expected.js b/test/js/samples/action/expected.js index 199bf4dffe08..f92f3723fe76 100644 --- a/test/js/samples/action/expected.js +++ b/test/js/samples/action/expected.js @@ -34,11 +34,11 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(a); - }, + d(detach) { + if (detach) { + detachNode(a); + } - d() { if (typeof link_action.destroy === 'function') link_action.destroy.call(component); } }; diff --git a/test/js/samples/bind-width-height/expected-bundle.js b/test/js/samples/bind-width-height/expected-bundle.js index 0787252e8df9..371f3d2843c5 100644 --- a/test/js/samples/bind-width-height/expected-bundle.js +++ b/test/js/samples/bind-width-height/expected-bundle.js @@ -58,8 +58,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -148,10 +147,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -161,7 +156,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -188,12 +182,13 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(div); - div_resize_listener.cancel(); - }, + d(detach) { + if (detach) { + detachNode(div); + } - d: noop + div_resize_listener.cancel(); + } }; } diff --git a/test/js/samples/bind-width-height/expected.js b/test/js/samples/bind-width-height/expected.js index 19014886a224..8d9b432ef0ea 100644 --- a/test/js/samples/bind-width-height/expected.js +++ b/test/js/samples/bind-width-height/expected.js @@ -22,12 +22,13 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(div); - div_resize_listener.cancel(); - }, + d(detach) { + if (detach) { + detachNode(div); + } - d: noop + div_resize_listener.cancel(); + } }; } 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 383cf6d7fce3..302c1c3aaf4d 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -34,8 +34,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -124,10 +123,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -137,7 +132,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -174,11 +168,11 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } diff --git a/test/js/samples/collapses-text-around-comments/expected.js b/test/js/samples/collapses-text-around-comments/expected.js index bbc1e187f6d6..75d00262c0d8 100644 --- a/test/js/samples/collapses-text-around-comments/expected.js +++ b/test/js/samples/collapses-text-around-comments/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; +import { appendNode, assign, createElement, createText, detachNode, init, insertNode, proto } from "svelte/shared.js"; function data() { return { foo: 42 } @@ -33,11 +33,11 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } diff --git a/test/js/samples/component-static-array/expected-bundle.js b/test/js/samples/component-static-array/expected-bundle.js index a210f5ce42c3..871a50c7cc5d 100644 --- a/test/js/samples/component-static-array/expected-bundle.js +++ b/test/js/samples/component-static-array/expected-bundle.js @@ -14,8 +14,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -104,10 +103,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -117,7 +112,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -144,12 +138,8 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - nested._unmount(); - }, - - d() { - nested.destroy(false); + d(detach) { + nested.destroy(detach); } }; } diff --git a/test/js/samples/component-static-array/expected.js b/test/js/samples/component-static-array/expected.js index cba2d4d947a8..f07b2d8ed366 100644 --- a/test/js/samples/component-static-array/expected.js +++ b/test/js/samples/component-static-array/expected.js @@ -22,12 +22,8 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - nested._unmount(); - }, - - d() { - nested.destroy(false); + d(detach) { + nested.destroy(detach); } }; } diff --git a/test/js/samples/component-static-immutable/expected-bundle.js b/test/js/samples/component-static-immutable/expected-bundle.js index 01c033904b27..93a558f4acef 100644 --- a/test/js/samples/component-static-immutable/expected-bundle.js +++ b/test/js/samples/component-static-immutable/expected-bundle.js @@ -14,8 +14,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -108,10 +107,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -121,7 +116,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -148,12 +142,8 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - nested._unmount(); - }, - - d() { - nested.destroy(false); + d(detach) { + nested.destroy(detach); } }; } diff --git a/test/js/samples/component-static-immutable/expected.js b/test/js/samples/component-static-immutable/expected.js index c7e5228e63ed..c18720c54ac8 100644 --- a/test/js/samples/component-static-immutable/expected.js +++ b/test/js/samples/component-static-immutable/expected.js @@ -22,12 +22,8 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - nested._unmount(); - }, - - d() { - nested.destroy(false); + d(detach) { + nested.destroy(detach); } }; } diff --git a/test/js/samples/component-static-immutable2/expected-bundle.js b/test/js/samples/component-static-immutable2/expected-bundle.js index 01c033904b27..93a558f4acef 100644 --- a/test/js/samples/component-static-immutable2/expected-bundle.js +++ b/test/js/samples/component-static-immutable2/expected-bundle.js @@ -14,8 +14,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -108,10 +107,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -121,7 +116,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -148,12 +142,8 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - nested._unmount(); - }, - - d() { - nested.destroy(false); + d(detach) { + nested.destroy(detach); } }; } diff --git a/test/js/samples/component-static-immutable2/expected.js b/test/js/samples/component-static-immutable2/expected.js index c7e5228e63ed..c18720c54ac8 100644 --- a/test/js/samples/component-static-immutable2/expected.js +++ b/test/js/samples/component-static-immutable2/expected.js @@ -22,12 +22,8 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - nested._unmount(); - }, - - d() { - nested.destroy(false); + d(detach) { + nested.destroy(detach); } }; } diff --git a/test/js/samples/component-static/expected-bundle.js b/test/js/samples/component-static/expected-bundle.js index 5af6703c7d2e..bf7121708aba 100644 --- a/test/js/samples/component-static/expected-bundle.js +++ b/test/js/samples/component-static/expected-bundle.js @@ -14,8 +14,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -104,10 +103,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -117,7 +112,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -144,12 +138,8 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - nested._unmount(); - }, - - d() { - nested.destroy(false); + d(detach) { + nested.destroy(detach); } }; } diff --git a/test/js/samples/component-static/expected.js b/test/js/samples/component-static/expected.js index fd7e83b2f5c4..206232418244 100644 --- a/test/js/samples/component-static/expected.js +++ b/test/js/samples/component-static/expected.js @@ -22,12 +22,8 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - nested._unmount(); - }, - - d() { - nested.destroy(false); + d(detach) { + nested.destroy(detach); } }; } diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index 0ea5200f7d32..1a44c576c579 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -14,8 +14,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -104,10 +103,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -117,7 +112,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -140,8 +134,6 @@ function create_main_fragment(component, ctx) { p: noop, - u: noop, - d: noop }; } diff --git a/test/js/samples/computed-collapsed-if/expected.js b/test/js/samples/computed-collapsed-if/expected.js index 5c248bf51544..8ca8d597ee54 100644 --- a/test/js/samples/computed-collapsed-if/expected.js +++ b/test/js/samples/computed-collapsed-if/expected.js @@ -18,8 +18,6 @@ function create_main_fragment(component, ctx) { p: noop, - u: noop, - d: noop }; } diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js index a2a6c24fb067..446ff232022a 100644 --- a/test/js/samples/css-media-query/expected-bundle.js +++ b/test/js/samples/css-media-query/expected-bundle.js @@ -30,8 +30,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -120,10 +119,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -133,7 +128,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -161,11 +155,11 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(div); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(div); + } + } }; } diff --git a/test/js/samples/css-media-query/expected.js b/test/js/samples/css-media-query/expected.js index eb786376551a..b307708cb322 100644 --- a/test/js/samples/css-media-query/expected.js +++ b/test/js/samples/css-media-query/expected.js @@ -23,11 +23,11 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(div); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(div); + } + } }; } diff --git a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js index e826a95e9276..86bef96e53a9 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js @@ -26,8 +26,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -116,10 +115,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -129,7 +124,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -151,11 +145,11 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(div); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(div); + } + } }; } @@ -189,10 +183,6 @@ assign(SvelteComponent.prototype, proto); assign(SvelteComponent.prototype, { _mount(target, anchor) { target.insertBefore(this, anchor); - }, - - _unmount() { - this.parentNode.removeChild(this); } }); diff --git a/test/js/samples/css-shadow-dom-keyframes/expected.js b/test/js/samples/css-shadow-dom-keyframes/expected.js index a5df6fa8f879..e86d8a3cb309 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected.js @@ -17,11 +17,11 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(div); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(div); + } + } }; } @@ -55,10 +55,6 @@ assign(SvelteComponent.prototype, proto); assign(SvelteComponent.prototype, { _mount(target, anchor) { target.insertBefore(this, anchor); - }, - - _unmount() { - this.parentNode.removeChild(this); } }); diff --git a/test/js/samples/deconflict-builtins/expected-bundle.js b/test/js/samples/deconflict-builtins/expected-bundle.js index 060e8d71c9ec..34f5c45b4a61 100644 --- a/test/js/samples/deconflict-builtins/expected-bundle.js +++ b/test/js/samples/deconflict-builtins/expected-bundle.js @@ -17,9 +17,9 @@ function detachNode(node) { node.parentNode.removeChild(node); } -function destroyEach(iterations) { +function destroyEach(iterations, detach) { for (var i = 0; i < iterations.length; i += 1) { - if (iterations[i]) iterations[i].d(); + if (iterations[i]) iterations[i].d(detach); } } @@ -44,8 +44,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -134,10 +133,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -147,7 +142,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -198,23 +192,18 @@ function create_main_fragment(component, ctx) { } for (; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - each_blocks[i].d(); + each_blocks[i].d(1); } each_blocks.length = each_value.length; } }, - u() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - } - - detachNode(each_anchor); - }, + d(detach) { + destroyEach(each_blocks, detach); - d() { - destroyEach(each_blocks); + if (detach) { + detachNode(each_anchor); + } } }; } @@ -240,11 +229,11 @@ function create_each_block(component, ctx) { } }, - u() { - detachNode(span); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(span); + } + } }; } diff --git a/test/js/samples/deconflict-builtins/expected.js b/test/js/samples/deconflict-builtins/expected.js index dd48b7708e80..9888cef86881 100644 --- a/test/js/samples/deconflict-builtins/expected.js +++ b/test/js/samples/deconflict-builtins/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createComment, createElement, createText, destroyEach, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; +import { appendNode, assign, createComment, createElement, createText, destroyEach, detachNode, init, insertNode, proto } from "svelte/shared.js"; function create_main_fragment(component, ctx) { var each_anchor; @@ -46,23 +46,18 @@ function create_main_fragment(component, ctx) { } for (; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - each_blocks[i].d(); + each_blocks[i].d(1); } each_blocks.length = each_value.length; } }, - u() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - } + d(detach) { + destroyEach(each_blocks, detach); - detachNode(each_anchor); - }, - - d() { - destroyEach(each_blocks); + if (detach) { + detachNode(each_anchor); + } } }; } @@ -88,11 +83,11 @@ function create_each_block(component, ctx) { } }, - u() { - detachNode(span); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(span); + } + } }; } diff --git a/test/js/samples/deconflict-globals/expected-bundle.js b/test/js/samples/deconflict-globals/expected-bundle.js index 304b7cd956d2..06e30f87bcaa 100644 --- a/test/js/samples/deconflict-globals/expected-bundle.js +++ b/test/js/samples/deconflict-globals/expected-bundle.js @@ -19,8 +19,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -109,10 +108,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -122,7 +117,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -146,8 +140,6 @@ function create_main_fragment(component, ctx) { p: noop, - u: noop, - d: noop }; } diff --git a/test/js/samples/deconflict-globals/expected.js b/test/js/samples/deconflict-globals/expected.js index a12da57b8a7d..afac48dfbd42 100644 --- a/test/js/samples/deconflict-globals/expected.js +++ b/test/js/samples/deconflict-globals/expected.js @@ -20,8 +20,6 @@ function create_main_fragment(component, ctx) { p: noop, - u: noop, - d: noop }; } diff --git a/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js b/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js index bea4d272dbdf..bb93b058410a 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js @@ -34,8 +34,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -142,10 +141,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var protoDev = { destroy: destroyDev, get, @@ -155,7 +150,6 @@ var protoDev = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -193,11 +187,11 @@ function create_main_fragment(component, ctx) { } }, - u: function unmount() { - detachNode(p); - }, - - d: noop + d: function destroy$$1(detach) { + if (detach) { + detachNode(p); + } + } }; } diff --git a/test/js/samples/dev-warning-missing-data-computed/expected.js b/test/js/samples/dev-warning-missing-data-computed/expected.js index 93be0ba0c197..5efb1f0a5ec4 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createElement, createText, detachNode, init, insertNode, noop, protoDev } from "svelte/shared.js"; +import { appendNode, assign, createElement, createText, detachNode, init, insertNode, protoDev } from "svelte/shared.js"; function bar({ foo }) { return foo * 2; @@ -33,11 +33,11 @@ function create_main_fragment(component, ctx) { } }, - u: function unmount() { - detachNode(p); - }, - - d: noop + d: function destroy(detach) { + if (detach) { + detachNode(p); + } + } }; } diff --git a/test/js/samples/do-use-dataset/expected-bundle.js b/test/js/samples/do-use-dataset/expected-bundle.js index 1c984cec898a..e30355de2502 100644 --- a/test/js/samples/do-use-dataset/expected-bundle.js +++ b/test/js/samples/do-use-dataset/expected-bundle.js @@ -30,8 +30,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -120,10 +119,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -133,7 +128,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -163,13 +157,13 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(div); + detachNode(text); + detachNode(div_1); + } + } }; } diff --git a/test/js/samples/do-use-dataset/expected.js b/test/js/samples/do-use-dataset/expected.js index 1ccda44fc71b..a57edb8483b2 100644 --- a/test/js/samples/do-use-dataset/expected.js +++ b/test/js/samples/do-use-dataset/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; +import { assign, createElement, createText, detachNode, init, insertNode, proto } from "svelte/shared.js"; function create_main_fragment(component, ctx) { var div, text, div_1; @@ -25,13 +25,13 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(div); + detachNode(text); + detachNode(div_1); + } + } }; } diff --git a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js index 70f961e65f58..3cbc5ca530f4 100644 --- a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js +++ b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js @@ -34,8 +34,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -124,10 +123,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -137,7 +132,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -167,13 +161,13 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(div); + detachNode(text); + detachNode(div_1); + } + } }; } diff --git a/test/js/samples/dont-use-dataset-in-legacy/expected.js b/test/js/samples/dont-use-dataset-in-legacy/expected.js index 812d20445559..1475687e2d47 100644 --- a/test/js/samples/dont-use-dataset-in-legacy/expected.js +++ b/test/js/samples/dont-use-dataset-in-legacy/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createElement, createText, detachNode, init, insertNode, noop, proto, setAttribute } from "svelte/shared.js"; +import { assign, createElement, createText, detachNode, init, insertNode, proto, setAttribute } from "svelte/shared.js"; function create_main_fragment(component, ctx) { var div, text, div_1; @@ -25,13 +25,13 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(div); + detachNode(text); + detachNode(div_1); + } + } }; } diff --git a/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js b/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js index c7e99cee1f10..80e1f6036685 100644 --- a/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js +++ b/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js @@ -34,8 +34,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -124,10 +123,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -137,7 +132,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -167,11 +161,11 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(svg); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(svg); + } + } }; } diff --git a/test/js/samples/dont-use-dataset-in-svg/expected.js b/test/js/samples/dont-use-dataset-in-svg/expected.js index 863062dc9108..42bc11876efc 100644 --- a/test/js/samples/dont-use-dataset-in-svg/expected.js +++ b/test/js/samples/dont-use-dataset-in-svg/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createSvgElement, detachNode, init, insertNode, noop, proto, setAttribute } from "svelte/shared.js"; +import { appendNode, assign, createSvgElement, detachNode, init, insertNode, proto, setAttribute } from "svelte/shared.js"; function create_main_fragment(component, ctx) { var svg, g, g_1; @@ -25,11 +25,11 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(svg); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(svg); + } + } }; } 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 e7f7e56af155..353346c2052a 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -23,9 +23,9 @@ function detachAfter(before) { } } -function destroyEach(iterations) { +function destroyEach(iterations, detach) { for (var i = 0; i < iterations.length; i += 1) { - if (iterations[i]) iterations[i].d(); + if (iterations[i]) iterations[i].d(detach); } } @@ -46,8 +46,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -136,10 +135,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -149,7 +144,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -204,8 +198,7 @@ function create_main_fragment(component, ctx) { } for (; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - each_blocks[i].d(); + each_blocks[i].d(1); } each_blocks.length = each_value.length; } @@ -215,17 +208,13 @@ function create_main_fragment(component, ctx) { } }, - u() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - } - - detachNode(text); - detachNode(p); - }, + d(detach) { + destroyEach(each_blocks, detach); - d() { - destroyEach(each_blocks); + if (detach) { + detachNode(text); + detachNode(p); + } } }; } @@ -281,13 +270,16 @@ function create_each_block(component, ctx) { } }, - u() { - detachAfter(raw_before); + d(detach) { + if (detach) { + detachAfter(raw_before); + } - detachNode(div); - }, - d: noop + if (detach) { + detachNode(div); + } + } }; } diff --git a/test/js/samples/each-block-changed-check/expected.js b/test/js/samples/each-block-changed-check/expected.js index 7febac791f6f..f36849384607 100644 --- a/test/js/samples/each-block-changed-check/expected.js +++ b/test/js/samples/each-block-changed-check/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createElement, createText, destroyEach, detachAfter, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; +import { appendNode, assign, createElement, createText, destroyEach, detachAfter, detachNode, init, insertNode, proto } from "svelte/shared.js"; function create_main_fragment(component, ctx) { var text, p, text_1; @@ -50,8 +50,7 @@ function create_main_fragment(component, ctx) { } for (; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - each_blocks[i].d(); + each_blocks[i].d(1); } each_blocks.length = each_value.length; } @@ -61,17 +60,13 @@ function create_main_fragment(component, ctx) { } }, - u() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - } + d(detach) { + destroyEach(each_blocks, detach); - detachNode(text); - detachNode(p); - }, - - d() { - destroyEach(each_blocks); + if (detach) { + detachNode(text); + detachNode(p); + } } }; } @@ -127,13 +122,16 @@ function create_each_block(component, ctx) { } }, - u() { - detachAfter(raw_before); + d(detach) { + if (detach) { + detachAfter(raw_before); + } - detachNode(div); - }, - d: noop + if (detach) { + detachNode(div); + } + } }; } diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index c66153dd23c9..10715bd84c33 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -26,8 +26,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -116,10 +115,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -129,7 +124,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -165,11 +159,11 @@ function create_main_fragment(component, ctx) { }, - u() { - detachNode(button); - }, + d(detach) { + if (detach) { + detachNode(button); + } - d() { foo_handler.destroy(); } }; diff --git a/test/js/samples/event-handlers-custom/expected.js b/test/js/samples/event-handlers-custom/expected.js index cc161cadaf33..86741c470c06 100644 --- a/test/js/samples/event-handlers-custom/expected.js +++ b/test/js/samples/event-handlers-custom/expected.js @@ -32,11 +32,11 @@ function create_main_fragment(component, ctx) { }, - u() { - detachNode(button); - }, + d(detach) { + if (detach) { + detachNode(button); + } - d() { foo_handler.destroy(); } }; diff --git a/test/js/samples/head-no-whitespace/expected-bundle.js b/test/js/samples/head-no-whitespace/expected-bundle.js index bee02e637f25..539ea3e5a4df 100644 --- a/test/js/samples/head-no-whitespace/expected-bundle.js +++ b/test/js/samples/head-no-whitespace/expected-bundle.js @@ -26,8 +26,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -116,10 +115,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -129,7 +124,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -155,12 +149,10 @@ function create_main_fragment(component, ctx) { p: noop, - u() { + d(detach) { detachNode(meta); detachNode(meta_1); - }, - - d: noop + } }; } diff --git a/test/js/samples/head-no-whitespace/expected.js b/test/js/samples/head-no-whitespace/expected.js index d0eb2ddcd95c..58b3f0e31185 100644 --- a/test/js/samples/head-no-whitespace/expected.js +++ b/test/js/samples/head-no-whitespace/expected.js @@ -21,12 +21,10 @@ function create_main_fragment(component, ctx) { p: noop, - u() { + d(detach) { detachNode(meta); detachNode(meta_1); - }, - - d: noop + } }; } 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 ce8d32f6240c..d54a62c22783 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -30,8 +30,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -120,10 +119,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -133,7 +128,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -163,21 +157,18 @@ function create_main_fragment(component, ctx) { p(changed, ctx) { if (current_block_type !== (current_block_type = select_block_type(ctx))) { - if_block.u(); - if_block.d(); + if_block.d(1); if_block = current_block_type(component, ctx); if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } }, - u() { - if_block.u(); - detachNode(if_block_anchor); - }, - - d() { - if_block.d(); + d(detach) { + if_block.d(detach); + if (detach) { + detachNode(if_block_anchor); + } } }; } @@ -196,11 +187,11 @@ function create_if_block(component, ctx) { insertNode(p, target, anchor); }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -218,11 +209,11 @@ function create_if_block_1(component, ctx) { insertNode(p, target, anchor); }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } diff --git a/test/js/samples/if-block-no-update/expected.js b/test/js/samples/if-block-no-update/expected.js index 783c4fc56c52..6bed171850a8 100644 --- a/test/js/samples/if-block-no-update/expected.js +++ b/test/js/samples/if-block-no-update/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createComment, createElement, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; +import { assign, createComment, createElement, detachNode, init, insertNode, proto } from "svelte/shared.js"; function create_main_fragment(component, ctx) { var if_block_anchor; @@ -25,21 +25,18 @@ function create_main_fragment(component, ctx) { p(changed, ctx) { if (current_block_type !== (current_block_type = select_block_type(ctx))) { - if_block.u(); - if_block.d(); + if_block.d(1); if_block = current_block_type(component, ctx); if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } }, - u() { - if_block.u(); - detachNode(if_block_anchor); - }, - - d() { - if_block.d(); + d(detach) { + if_block.d(detach); + if (detach) { + detachNode(if_block_anchor); + } } }; } @@ -58,11 +55,11 @@ function create_if_block(component, ctx) { insertNode(p, target, anchor); }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -80,11 +77,11 @@ function create_if_block_1(component, ctx) { insertNode(p, target, anchor); }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js index ee5b87f32ce3..9a067201fbf8 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -30,8 +30,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -120,10 +119,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -133,7 +128,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -163,19 +157,16 @@ function create_main_fragment(component, ctx) { if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { - if_block.u(); - if_block.d(); + if_block.d(1); if_block = null; } }, - u() { - if (if_block) if_block.u(); - detachNode(if_block_anchor); - }, - - d() { - if (if_block) if_block.d(); + d(detach) { + if (if_block) if_block.d(detach); + if (detach) { + detachNode(if_block_anchor); + } } }; } @@ -194,11 +185,11 @@ function create_if_block(component, ctx) { insertNode(p, target, anchor); }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } diff --git a/test/js/samples/if-block-simple/expected.js b/test/js/samples/if-block-simple/expected.js index ae583b652acd..98458d918fff 100644 --- a/test/js/samples/if-block-simple/expected.js +++ b/test/js/samples/if-block-simple/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createComment, createElement, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; +import { assign, createComment, createElement, detachNode, init, insertNode, proto } from "svelte/shared.js"; function create_main_fragment(component, ctx) { var if_block_anchor; @@ -25,19 +25,16 @@ function create_main_fragment(component, ctx) { if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { - if_block.u(); - if_block.d(); + if_block.d(1); if_block = null; } }, - u() { - if (if_block) if_block.u(); - detachNode(if_block_anchor); - }, - - d() { - if (if_block) if_block.d(); + d(detach) { + if (if_block) if_block.d(detach); + if (detach) { + detachNode(if_block_anchor); + } } }; } @@ -56,11 +53,11 @@ function create_if_block(component, ctx) { insertNode(p, target, anchor); }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } diff --git a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js index 64b9e9f612a7..13da6e5fc0aa 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js @@ -30,8 +30,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -120,10 +119,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -133,7 +128,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -163,11 +157,11 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(div); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(div); + } + } }; } diff --git a/test/js/samples/inline-style-optimized-multiple/expected.js b/test/js/samples/inline-style-optimized-multiple/expected.js index d44a56e57af4..742da2b3d9ec 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected.js +++ b/test/js/samples/inline-style-optimized-multiple/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createElement, detachNode, init, insertNode, noop, proto, setStyle } from "svelte/shared.js"; +import { assign, createElement, detachNode, init, insertNode, proto, setStyle } from "svelte/shared.js"; function create_main_fragment(component, ctx) { var div; @@ -25,11 +25,11 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(div); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(div); + } + } }; } diff --git a/test/js/samples/inline-style-optimized-url/expected-bundle.js b/test/js/samples/inline-style-optimized-url/expected-bundle.js index 9d66c5d9d301..f27fd1f154f3 100644 --- a/test/js/samples/inline-style-optimized-url/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-url/expected-bundle.js @@ -30,8 +30,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -120,10 +119,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -133,7 +128,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -158,11 +152,11 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(div); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(div); + } + } }; } diff --git a/test/js/samples/inline-style-optimized-url/expected.js b/test/js/samples/inline-style-optimized-url/expected.js index b6ade43a350e..2eb51e081805 100644 --- a/test/js/samples/inline-style-optimized-url/expected.js +++ b/test/js/samples/inline-style-optimized-url/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createElement, detachNode, init, insertNode, noop, proto, setStyle } from "svelte/shared.js"; +import { assign, createElement, detachNode, init, insertNode, proto, setStyle } from "svelte/shared.js"; function create_main_fragment(component, ctx) { var div; @@ -20,11 +20,11 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(div); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(div); + } + } }; } diff --git a/test/js/samples/inline-style-optimized/expected-bundle.js b/test/js/samples/inline-style-optimized/expected-bundle.js index dea96b427bdf..1df7465c86f8 100644 --- a/test/js/samples/inline-style-optimized/expected-bundle.js +++ b/test/js/samples/inline-style-optimized/expected-bundle.js @@ -30,8 +30,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -120,10 +119,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -133,7 +128,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -158,11 +152,11 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(div); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(div); + } + } }; } diff --git a/test/js/samples/inline-style-optimized/expected.js b/test/js/samples/inline-style-optimized/expected.js index 9574f5d19648..9c55bc6e8451 100644 --- a/test/js/samples/inline-style-optimized/expected.js +++ b/test/js/samples/inline-style-optimized/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createElement, detachNode, init, insertNode, noop, proto, setStyle } from "svelte/shared.js"; +import { assign, createElement, detachNode, init, insertNode, proto, setStyle } from "svelte/shared.js"; function create_main_fragment(component, ctx) { var div; @@ -20,11 +20,11 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(div); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(div); + } + } }; } diff --git a/test/js/samples/inline-style-unoptimized/expected-bundle.js b/test/js/samples/inline-style-unoptimized/expected-bundle.js index 3719ea158755..ed8e4fd01cf6 100644 --- a/test/js/samples/inline-style-unoptimized/expected-bundle.js +++ b/test/js/samples/inline-style-unoptimized/expected-bundle.js @@ -30,8 +30,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -120,10 +119,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -133,7 +128,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -167,13 +161,13 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(div); + detachNode(text); + detachNode(div_1); + } + } }; } diff --git a/test/js/samples/inline-style-unoptimized/expected.js b/test/js/samples/inline-style-unoptimized/expected.js index a1fc3d49f478..41ffd501e014 100644 --- a/test/js/samples/inline-style-unoptimized/expected.js +++ b/test/js/samples/inline-style-unoptimized/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { assign, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; +import { assign, createElement, createText, detachNode, init, insertNode, proto } from "svelte/shared.js"; function create_main_fragment(component, ctx) { var div, text, div_1, div_1_style_value; @@ -29,13 +29,13 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(div); + detachNode(text); + detachNode(div_1); + } + } }; } diff --git a/test/js/samples/input-without-blowback-guard/expected-bundle.js b/test/js/samples/input-without-blowback-guard/expected-bundle.js index 6c5b71709638..67915bc81b61 100644 --- a/test/js/samples/input-without-blowback-guard/expected-bundle.js +++ b/test/js/samples/input-without-blowback-guard/expected-bundle.js @@ -38,8 +38,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -128,10 +127,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -141,7 +136,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -171,11 +165,11 @@ function create_main_fragment(component, ctx) { input.checked = ctx.foo; }, - u() { - detachNode(input); - }, + d(detach) { + if (detach) { + detachNode(input); + } - d() { removeListener(input, "change", input_change_handler); } }; diff --git a/test/js/samples/input-without-blowback-guard/expected.js b/test/js/samples/input-without-blowback-guard/expected.js index 7aee1cb40770..635987f16b4f 100644 --- a/test/js/samples/input-without-blowback-guard/expected.js +++ b/test/js/samples/input-without-blowback-guard/expected.js @@ -25,11 +25,11 @@ function create_main_fragment(component, ctx) { input.checked = ctx.foo; }, - u() { - detachNode(input); - }, + d(detach) { + if (detach) { + detachNode(input); + } - d() { removeListener(input, "change", input_change_handler); } }; diff --git a/test/js/samples/legacy-input-type/expected-bundle.js b/test/js/samples/legacy-input-type/expected-bundle.js index b3469f786494..9f806ed42a0c 100644 --- a/test/js/samples/legacy-input-type/expected-bundle.js +++ b/test/js/samples/legacy-input-type/expected-bundle.js @@ -32,8 +32,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -122,10 +121,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -135,7 +130,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -156,11 +150,11 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(input); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(input); + } + } }; } diff --git a/test/js/samples/legacy-input-type/expected.js b/test/js/samples/legacy-input-type/expected.js index 89e31fa479ac..2e1c279b2080 100644 --- a/test/js/samples/legacy-input-type/expected.js +++ b/test/js/samples/legacy-input-type/expected.js @@ -16,11 +16,11 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(input); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(input); + } + } }; } diff --git a/test/js/samples/media-bindings/expected-bundle.js b/test/js/samples/media-bindings/expected-bundle.js index 8013f2b11f40..fbb235a80d16 100644 --- a/test/js/samples/media-bindings/expected-bundle.js +++ b/test/js/samples/media-bindings/expected-bundle.js @@ -42,8 +42,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -132,10 +131,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -145,7 +140,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -214,11 +208,11 @@ function create_main_fragment(component, ctx) { if (!audio_updating && !isNaN(ctx.volume)) audio.volume = ctx.volume; }, - u() { - detachNode(audio); - }, + d(detach) { + if (detach) { + detachNode(audio); + } - d() { removeListener(audio, "timeupdate", audio_timeupdate_handler); removeListener(audio, "durationchange", audio_durationchange_handler); removeListener(audio, "play", audio_play_pause_handler); diff --git a/test/js/samples/media-bindings/expected.js b/test/js/samples/media-bindings/expected.js index 2b4c3b627ce1..f2400877e23b 100644 --- a/test/js/samples/media-bindings/expected.js +++ b/test/js/samples/media-bindings/expected.js @@ -64,11 +64,11 @@ function create_main_fragment(component, ctx) { if (!audio_updating && !isNaN(ctx.volume)) audio.volume = ctx.volume; }, - u() { - detachNode(audio); - }, + d(detach) { + if (detach) { + detachNode(audio); + } - d() { removeListener(audio, "timeupdate", audio_timeupdate_handler); removeListener(audio, "durationchange", audio_durationchange_handler); removeListener(audio, "play", audio_play_pause_handler); diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index 0611137fb900..bfab868082d2 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -28,8 +28,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -118,10 +117,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -131,7 +126,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -165,15 +159,13 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - imported._unmount(); - detachNode(text); - nonimported._unmount(); - }, + d(detach) { + imported.destroy(detach); + if (detach) { + detachNode(text); + } - d() { - imported.destroy(false); - nonimported.destroy(false); + nonimported.destroy(detach); } }; } diff --git a/test/js/samples/non-imported-component/expected.js b/test/js/samples/non-imported-component/expected.js index 4af36115422f..c070fa76d442 100644 --- a/test/js/samples/non-imported-component/expected.js +++ b/test/js/samples/non-imported-component/expected.js @@ -30,15 +30,13 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - imported._unmount(); - detachNode(text); - nonimported._unmount(); - }, + d(detach) { + imported.destroy(detach); + if (detach) { + detachNode(text); + } - d() { - imported.destroy(false); - nonimported.destroy(false); + nonimported.destroy(detach); } }; } diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js index 83c58b1f4132..30d69d6180ce 100644 --- a/test/js/samples/setup-method/expected-bundle.js +++ b/test/js/samples/setup-method/expected-bundle.js @@ -14,8 +14,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -104,10 +103,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -117,7 +112,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -148,8 +142,6 @@ function create_main_fragment(component, ctx) { p: noop, - u: noop, - d: noop }; } diff --git a/test/js/samples/setup-method/expected.js b/test/js/samples/setup-method/expected.js index cb565b0f747f..855e7635b0a3 100644 --- a/test/js/samples/setup-method/expected.js +++ b/test/js/samples/setup-method/expected.js @@ -26,8 +26,6 @@ function create_main_fragment(component, ctx) { p: noop, - u: noop, - d: noop }; } diff --git a/test/js/samples/svg-title/expected-bundle.js b/test/js/samples/svg-title/expected-bundle.js index c80b95ef786a..faf86f14cbfd 100644 --- a/test/js/samples/svg-title/expected-bundle.js +++ b/test/js/samples/svg-title/expected-bundle.js @@ -34,8 +34,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -124,10 +123,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -137,7 +132,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -161,11 +155,11 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(svg); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(svg); + } + } }; } diff --git a/test/js/samples/svg-title/expected.js b/test/js/samples/svg-title/expected.js index df05dc331f47..96a1ea09d1e1 100644 --- a/test/js/samples/svg-title/expected.js +++ b/test/js/samples/svg-title/expected.js @@ -19,11 +19,11 @@ function create_main_fragment(component, ctx) { p: noop, - u() { - detachNode(svg); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(svg); + } + } }; } diff --git a/test/js/samples/title/expected-bundle.js b/test/js/samples/title/expected-bundle.js index 10972a30e799..1c4fd5e84fad 100644 --- a/test/js/samples/title/expected-bundle.js +++ b/test/js/samples/title/expected-bundle.js @@ -14,8 +14,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -104,10 +103,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -117,7 +112,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -139,8 +133,6 @@ function create_main_fragment(component, ctx) { } }, - u: noop, - d: noop }; } diff --git a/test/js/samples/title/expected.js b/test/js/samples/title/expected.js index 75ef8925a3f0..f5aa312569f6 100644 --- a/test/js/samples/title/expected.js +++ b/test/js/samples/title/expected.js @@ -17,8 +17,6 @@ function create_main_fragment(component, ctx) { } }, - u: noop, - d: noop }; } 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 90d0e364388e..3a3879b91e83 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -38,8 +38,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -128,10 +127,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -141,7 +136,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -207,8 +201,7 @@ function create_main_fragment(component, ctx) { if_block.m(div, text); } } else if (if_block) { - if_block.u(); - if_block.d(); + if_block.d(1); if_block = null; } @@ -219,8 +212,7 @@ function create_main_fragment(component, ctx) { if_block_1.m(div, text_3); } } else if (if_block_1) { - if_block_1.u(); - if_block_1.d(); + if_block_1.d(1); if_block_1 = null; } @@ -231,8 +223,7 @@ function create_main_fragment(component, ctx) { if_block_2.m(div, text_4); } } else if (if_block_2) { - if_block_2.u(); - if_block_2.d(); + if_block_2.d(1); if_block_2 = null; } @@ -243,8 +234,7 @@ function create_main_fragment(component, ctx) { if_block_3.m(div, null); } } else if (if_block_3) { - if_block_3.u(); - if_block_3.d(); + if_block_3.d(1); if_block_3 = null; } @@ -255,29 +245,28 @@ function create_main_fragment(component, ctx) { if_block_4.m(if_block_4_anchor.parentNode, if_block_4_anchor); } } else if (if_block_4) { - if_block_4.u(); - if_block_4.d(); + if_block_4.d(1); if_block_4 = null; } }, - u() { - detachNode(div); - if (if_block) if_block.u(); - if (if_block_1) if_block_1.u(); - if (if_block_2) if_block_2.u(); - if (if_block_3) if_block_3.u(); - detachNode(text_8); - if (if_block_4) if_block_4.u(); - detachNode(if_block_4_anchor); - }, + d(detach) { + if (detach) { + detachNode(div); + } - d() { if (if_block) if_block.d(); if (if_block_1) if_block_1.d(); if (if_block_2) if_block_2.d(); if (if_block_3) if_block_3.d(); - if (if_block_4) if_block_4.d(); + if (detach) { + detachNode(text_8); + } + + if (if_block_4) if_block_4.d(detach); + if (detach) { + detachNode(if_block_4_anchor); + } } }; } @@ -296,11 +285,11 @@ function create_if_block(component, ctx) { insertNode(p, target, anchor); }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -318,11 +307,11 @@ function create_if_block_1(component, ctx) { insertNode(p, target, anchor); }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -340,11 +329,11 @@ function create_if_block_2(component, ctx) { insertNode(p, target, anchor); }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -362,11 +351,11 @@ function create_if_block_3(component, ctx) { insertNode(p, target, anchor); }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -384,11 +373,11 @@ function create_if_block_4(component, ctx) { insertNode(p, target, anchor); }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } diff --git a/test/js/samples/use-elements-as-anchors/expected.js b/test/js/samples/use-elements-as-anchors/expected.js index 26b782988efc..9e33cb6e03e9 100644 --- a/test/js/samples/use-elements-as-anchors/expected.js +++ b/test/js/samples/use-elements-as-anchors/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createComment, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; +import { appendNode, assign, createComment, createElement, createText, detachNode, init, insertNode, proto } from "svelte/shared.js"; function create_main_fragment(component, ctx) { var div, text, p, text_2, text_3, text_4, p_1, text_6, text_8, if_block_4_anchor; @@ -61,8 +61,7 @@ function create_main_fragment(component, ctx) { if_block.m(div, text); } } else if (if_block) { - if_block.u(); - if_block.d(); + if_block.d(1); if_block = null; } @@ -73,8 +72,7 @@ function create_main_fragment(component, ctx) { if_block_1.m(div, text_3); } } else if (if_block_1) { - if_block_1.u(); - if_block_1.d(); + if_block_1.d(1); if_block_1 = null; } @@ -85,8 +83,7 @@ function create_main_fragment(component, ctx) { if_block_2.m(div, text_4); } } else if (if_block_2) { - if_block_2.u(); - if_block_2.d(); + if_block_2.d(1); if_block_2 = null; } @@ -97,8 +94,7 @@ function create_main_fragment(component, ctx) { if_block_3.m(div, null); } } else if (if_block_3) { - if_block_3.u(); - if_block_3.d(); + if_block_3.d(1); if_block_3 = null; } @@ -109,29 +105,28 @@ function create_main_fragment(component, ctx) { if_block_4.m(if_block_4_anchor.parentNode, if_block_4_anchor); } } else if (if_block_4) { - if_block_4.u(); - if_block_4.d(); + if_block_4.d(1); if_block_4 = null; } }, - u() { - detachNode(div); - if (if_block) if_block.u(); - if (if_block_1) if_block_1.u(); - if (if_block_2) if_block_2.u(); - if (if_block_3) if_block_3.u(); - detachNode(text_8); - if (if_block_4) if_block_4.u(); - detachNode(if_block_4_anchor); - }, + d(detach) { + if (detach) { + detachNode(div); + } - d() { if (if_block) if_block.d(); if (if_block_1) if_block_1.d(); if (if_block_2) if_block_2.d(); if (if_block_3) if_block_3.d(); - if (if_block_4) if_block_4.d(); + if (detach) { + detachNode(text_8); + } + + if (if_block_4) if_block_4.d(detach); + if (detach) { + detachNode(if_block_4_anchor); + } } }; } @@ -150,11 +145,11 @@ function create_if_block(component, ctx) { insertNode(p, target, anchor); }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -172,11 +167,11 @@ function create_if_block_1(component, ctx) { insertNode(p, target, anchor); }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -194,11 +189,11 @@ function create_if_block_2(component, ctx) { insertNode(p, target, anchor); }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -216,11 +211,11 @@ function create_if_block_3(component, ctx) { insertNode(p, target, anchor); }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } @@ -238,11 +233,11 @@ function create_if_block_4(component, ctx) { insertNode(p, target, anchor); }, - u() { - detachNode(p); - }, - - d: noop + d(detach) { + if (detach) { + detachNode(p); + } + } }; } diff --git a/test/js/samples/window-binding-scroll/expected-bundle.js b/test/js/samples/window-binding-scroll/expected-bundle.js index 82f3eaf27a14..a26fb90ce58c 100644 --- a/test/js/samples/window-binding-scroll/expected-bundle.js +++ b/test/js/samples/window-binding-scroll/expected-bundle.js @@ -34,8 +34,7 @@ function destroy(detach) { this.fire('destroy'); this.set = noop; - if (detach !== false) this._fragment.u(); - this._fragment.d(); + this._fragment.d(detach !== false); this._fragment = null; this._state = {}; } @@ -124,10 +123,6 @@ function _mount(target, anchor) { this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); } -function _unmount() { - if (this._fragment) this._fragment.u(); -} - var proto = { destroy, get, @@ -137,7 +132,6 @@ var proto = { _recompute: noop, _set, _mount, - _unmount, _differs }; @@ -185,12 +179,12 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(p); - }, - - d() { + d(detach) { window.removeEventListener("scroll", onwindowscroll); + + if (detach) { + detachNode(p); + } } }; } diff --git a/test/js/samples/window-binding-scroll/expected.js b/test/js/samples/window-binding-scroll/expected.js index 2416e70f94a7..ce8a8213b64a 100644 --- a/test/js/samples/window-binding-scroll/expected.js +++ b/test/js/samples/window-binding-scroll/expected.js @@ -43,12 +43,12 @@ function create_main_fragment(component, ctx) { } }, - u() { - detachNode(p); - }, - - d() { + d(detach) { window.removeEventListener("scroll", onwindowscroll); + + if (detach) { + detachNode(p); + } } }; } diff --git a/test/runtime/samples/await-then-catch-if/main.html b/test/runtime/samples/await-then-catch-if/main.html index f9684c82576f..bdeb5a7f5ef9 100644 --- a/test/runtime/samples/await-then-catch-if/main.html +++ b/test/runtime/samples/await-then-catch-if/main.html @@ -1,11 +1,11 @@ {#if show} -{#await thePromise} -

loading...

-{:then theValue} -

the value is {theValue}

-{:catch theError} -

oh no! {theError.message}

-{/await} + {#await thePromise} +

loading...

+ {:then theValue} +

the value is {theValue}

+ {:catch theError} +

oh no! {theError.message}

+ {/await} {:else} -

Else

+

Else

{/if} From a18be798876d4519ff6a1f64ddf8494f3e303440 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 5 May 2018 17:17:59 -0400 Subject: [PATCH 3/3] simplify handling of html blocks --- src/compile/dom/Block.ts | 11 +++-------- src/compile/nodes/RawMustacheTag.ts | 10 ++++++++-- .../each-block-changed-check/expected-bundle.js | 5 ----- test/js/samples/each-block-changed-check/expected.js | 5 ----- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/compile/dom/Block.ts b/src/compile/dom/Block.ts index c9010cf7022f..7c1bcc857361 100644 --- a/src/compile/dom/Block.ts +++ b/src/compile/dom/Block.ts @@ -34,7 +34,6 @@ export default class Block { intro: CodeBuilder; update: CodeBuilder; outro: CodeBuilder; - detachRaw: CodeBuilder; destroy: CodeBuilder; }; @@ -72,7 +71,6 @@ export default class Block { intro: new CodeBuilder(), update: new CodeBuilder(), outro: new CodeBuilder(), - detachRaw: new CodeBuilder(), destroy: new CodeBuilder(), }; @@ -101,7 +99,8 @@ export default class Block { name: string, renderStatement: string, claimStatement: string, - parentNode: string + parentNode: string, + noDetach?: boolean ) { this.addVariable(name); this.builders.create.addLine(`${name} = ${renderStatement};`); @@ -112,7 +111,7 @@ export default class Block { if (parentNode === 'document.head') this.builders.destroy.addLine(`@detachNode(${name});`); } else { this.builders.mount.addLine(`@insertNode(${name}, #target, anchor);`); - this.builders.destroy.addConditional('detach', `@detachNode(${name});`); + if (!noDetach) this.builders.destroy.addConditional('detach', `@detachNode(${name});`); } } @@ -159,10 +158,6 @@ export default class Block { this.builders.mount.addLine(`${this.autofocus}.focus();`); } - // minor hack – we need to ensure that any {@html x} blocks are detached first - // (TODO: is this still necessary? or is there a neater approach?) - this.builders.destroy.addBlockAtStart(this.builders.detachRaw.toString()); - const properties = new CodeBuilder(); let localKey; diff --git a/src/compile/nodes/RawMustacheTag.ts b/src/compile/nodes/RawMustacheTag.ts index 5cfc4b50587a..2e65b21fed62 100644 --- a/src/compile/nodes/RawMustacheTag.ts +++ b/src/compile/nodes/RawMustacheTag.ts @@ -56,7 +56,8 @@ export default class RawMustacheTag extends Tag { anchorBefore, `@createElement('noscript')`, parentNodes && `@createElement('noscript')`, - parentNode + parentNode, + true ); } @@ -76,7 +77,12 @@ export default class RawMustacheTag extends Tag { } block.builders.mount.addLine(insert(init)); - block.builders.detachRaw.addConditional('detach', detach); + + if (!parentNode) { + block.builders.destroy.addConditional('detach', needsAnchorBefore + ? `${detach}\n@detachNode(${anchorBefore});` + : detach); + } if (needsAnchorAfter && anchorBefore !== 'null') { // ...otherwise it should go afterwards 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 353346c2052a..6e9c736bc588 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -271,11 +271,6 @@ function create_each_block(component, ctx) { }, d(detach) { - if (detach) { - detachAfter(raw_before); - } - - if (detach) { detachNode(div); } diff --git a/test/js/samples/each-block-changed-check/expected.js b/test/js/samples/each-block-changed-check/expected.js index f36849384607..2be560eb6db9 100644 --- a/test/js/samples/each-block-changed-check/expected.js +++ b/test/js/samples/each-block-changed-check/expected.js @@ -123,11 +123,6 @@ function create_each_block(component, ctx) { }, d(detach) { - if (detach) { - detachAfter(raw_before); - } - - if (detach) { detachNode(div); }