From 7d4dcdf53105f1cef87321f54ce70de139d5ea50 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 28 May 2017 11:53:19 -0400 Subject: [PATCH] update tests --- .../expected-bundle.js | 15 +-- .../expected.js | 15 +-- .../computed-collapsed-if/expected-bundle.js | 5 +- .../samples/computed-collapsed-if/expected.js | 5 +- .../expected-bundle.js | 39 +++++--- .../each-block-changed-check/expected.js | 38 ++++--- .../event-handlers-custom/expected-bundle.js | 13 +-- .../samples/event-handlers-custom/expected.js | 13 +-- .../if-block-no-update/expected-bundle.js | 43 ++++---- .../js/samples/if-block-no-update/expected.js | 43 ++++---- .../if-block-simple/expected-bundle.js | 29 +++--- test/js/samples/if-block-simple/expected.js | 29 +++--- .../non-imported-component/expected-bundle.js | 17 ++-- .../non-imported-component/expected.js | 17 ++-- .../expected-bundle.js | 5 +- .../onrender-onteardown-rewritten/expected.js | 5 +- .../expected-bundle.js | 99 +++++++++++-------- .../use-elements-as-anchors/expected.js | 99 ++++++++++--------- 18 files changed, 310 insertions(+), 219 deletions(-) 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 6372e1ef4f..8d4fe1fa29 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -1,3 +1,5 @@ +function noop () {} + function assign ( target ) { for ( var i = 1; i < arguments.length; i += 1 ) { var source = arguments[i]; @@ -160,11 +162,11 @@ function create_main_fragment ( state, component ) { } }, - destroy: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -202,7 +204,8 @@ SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.destroy( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy( false ); // TODO no arguments to destroy this._fragment = null; this._state = {}; diff --git a/test/js/samples/collapses-text-around-comments/expected.js b/test/js/samples/collapses-text-around-comments/expected.js index 8145330e3e..8e9ad3ba19 100644 --- a/test/js/samples/collapses-text-around-comments/expected.js +++ b/test/js/samples/collapses-text-around-comments/expected.js @@ -1,4 +1,4 @@ -import { appendNode, assign, createElement, createText, detachNode, dispatchObservers, insertNode, proto, setAttribute } from "svelte/shared.js"; +import { appendNode, assign, createElement, createText, detachNode, dispatchObservers, insertNode, noop, proto, setAttribute } from "svelte/shared.js"; var template = (function () { return { @@ -34,11 +34,11 @@ function create_main_fragment ( state, component ) { } }, - destroy: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -76,7 +76,8 @@ SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.destroy( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy( false ); // TODO no arguments to destroy this._fragment = null; this._state = {}; diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index 65a703f19b..823a40e235 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -126,6 +126,8 @@ function create_main_fragment ( state, component ) { return { mount: noop, + unmount: noop, + destroy: noop }; } @@ -164,7 +166,8 @@ SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.destroy( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy( false ); // TODO no arguments to destroy this._fragment = null; this._state = {}; diff --git a/test/js/samples/computed-collapsed-if/expected.js b/test/js/samples/computed-collapsed-if/expected.js index df9295d28b..d627a99912 100644 --- a/test/js/samples/computed-collapsed-if/expected.js +++ b/test/js/samples/computed-collapsed-if/expected.js @@ -22,6 +22,8 @@ function create_main_fragment ( state, component ) { return { mount: noop, + unmount: noop, + destroy: noop }; } @@ -60,7 +62,8 @@ SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.destroy( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy( false ); // TODO no arguments to destroy this._fragment = null; this._state = {}; 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 95a876bad5..ef61a29a1d 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -1,3 +1,5 @@ +function noop () {} + function assign ( target ) { for ( var i = 1; i < arguments.length; i += 1 ) { var source = arguments[i]; @@ -25,6 +27,7 @@ function detachBetween ( before, after ) { } } +// TODO this is out of date function destroyEach ( iterations, detach, start ) { for ( var i = start; i < iterations.length; i += 1 ) { if ( iterations[i] ) iterations[i].destroy( detach ); @@ -173,7 +176,10 @@ function create_main_fragment ( state, component ) { } } - destroyEach( each_block_iterations, true, each_block_value.length ); + for ( ; i < each_block_iterations.length; i += 1 ) { + each_block_iterations[i].unmount(); + each_block_iterations[i].destroy(); + } each_block_iterations.length = each_block_value.length; } @@ -182,13 +188,17 @@ function create_main_fragment ( state, component ) { } }, - destroy: function ( detach ) { - destroyEach( each_block_iterations, detach, 0 ); - - if ( detach ) { - detachNode( text ); - detachNode( p ); + unmount: function () { + for ( var i = 0; i < each_block_iterations.length; i += 1 ) { + each_block_iterations[i].unmount(); } + + detachNode( text ); + detachNode( p ); + }, + + destroy: function () { + destroyEach( each_block_iterations, false, 0 ); } }; } @@ -244,13 +254,13 @@ function create_each_block ( state, each_block_value, comment, i, component ) { } }, - destroy: function ( detach ) { - if ( detach ) { - detachBetween( raw_before, raw_after ); + unmount: function () { + detachBetween( raw_before, raw_after ); - detachNode( div ); - } - } + detachNode( div ); + }, + + destroy: noop }; } @@ -287,7 +297,8 @@ SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.destroy( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy( false ); // TODO no arguments to destroy this._fragment = null; this._state = {}; diff --git a/test/js/samples/each-block-changed-check/expected.js b/test/js/samples/each-block-changed-check/expected.js index 128d332196..af2a1ca484 100644 --- a/test/js/samples/each-block-changed-check/expected.js +++ b/test/js/samples/each-block-changed-check/expected.js @@ -1,4 +1,4 @@ -import { appendNode, assign, createElement, createText, destroyEach, detachBetween, detachNode, dispatchObservers, insertNode, proto } from "svelte/shared.js"; +import { appendNode, assign, createElement, createText, destroyEach, detachBetween, detachNode, dispatchObservers, insertNode, noop, proto } from "svelte/shared.js"; function create_main_fragment ( state, component ) { var text_1_value; @@ -39,7 +39,10 @@ function create_main_fragment ( state, component ) { } } - destroyEach( each_block_iterations, true, each_block_value.length ); + for ( ; i < each_block_iterations.length; i += 1 ) { + each_block_iterations[i].unmount(); + each_block_iterations[i].destroy(); + } each_block_iterations.length = each_block_value.length; } @@ -48,13 +51,17 @@ function create_main_fragment ( state, component ) { } }, - destroy: function ( detach ) { - destroyEach( each_block_iterations, detach, 0 ); - - if ( detach ) { - detachNode( text ); - detachNode( p ); + unmount: function () { + for ( var i = 0; i < each_block_iterations.length; i += 1 ) { + each_block_iterations[i].unmount(); } + + detachNode( text ); + detachNode( p ); + }, + + destroy: function () { + destroyEach( each_block_iterations, false, 0 ); } }; } @@ -110,13 +117,13 @@ function create_each_block ( state, each_block_value, comment, i, component ) { } }, - destroy: function ( detach ) { - if ( detach ) { - detachBetween( raw_before, raw_after ); + unmount: function () { + detachBetween( raw_before, raw_after ); - detachNode( div ); - } - } + detachNode( div ); + }, + + destroy: noop }; } @@ -153,7 +160,8 @@ SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.destroy( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy( false ); // TODO no arguments to destroy this._fragment = null; this._state = {}; diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index 7fae3fe412..776d0b7367 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -152,12 +152,12 @@ function create_main_fragment ( state, component ) { insertNode( button, target, anchor ); }, - destroy: function ( detach ) { - foo_handler.teardown(); + unmount: function () { + detachNode( button ); + }, - if ( detach ) { - detachNode( button ); - } + destroy: function () { + foo_handler.teardown(); } }; } @@ -194,7 +194,8 @@ SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.destroy( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy( false ); // TODO no arguments to destroy this._fragment = null; this._state = {}; diff --git a/test/js/samples/event-handlers-custom/expected.js b/test/js/samples/event-handlers-custom/expected.js index ed40aae9df..a193b30993 100644 --- a/test/js/samples/event-handlers-custom/expected.js +++ b/test/js/samples/event-handlers-custom/expected.js @@ -30,12 +30,12 @@ function create_main_fragment ( state, component ) { insertNode( button, target, anchor ); }, - destroy: function ( detach ) { - foo_handler.teardown(); + unmount: function () { + detachNode( button ); + }, - if ( detach ) { - detachNode( button ); - } + destroy: function () { + foo_handler.teardown(); } }; } @@ -72,7 +72,8 @@ SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.destroy( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy( false ); // TODO no arguments to destroy this._fragment = null; this._state = {}; 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 29b6104b9b..6119a9ca37 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -1,3 +1,5 @@ +function noop () {} + function assign ( target ) { for ( var i = 1; i < arguments.length; i += 1 ) { var source = arguments[i]; @@ -145,18 +147,24 @@ function create_main_fragment ( state, component ) { update: function ( changed, state ) { if ( current_block !== ( current_block = get_block( state ) ) ) { - if_block.destroy( true ); + { + if_block.unmount(); + if_block.destroy(); + } if_block = current_block( state, component ); if_block.mount( if_block_anchor.parentNode, if_block_anchor ); } }, - destroy: function ( detach ) { - if_block.destroy( detach ); + unmount: function () { + detachNode( if_block_anchor ); + }, - if ( detach ) { - detachNode( if_block_anchor ); - } + destroy: function () { + { + if_block.unmount(); + if_block.destroy(); + } } }; } @@ -170,11 +178,11 @@ function create_if_block ( state, component ) { insertNode( p, target, anchor ); }, - destroy: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -187,11 +195,11 @@ function create_if_block_1 ( state, component ) { insertNode( p, target, anchor ); }, - destroy: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -228,7 +236,8 @@ SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.destroy( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy( false ); // TODO no arguments to destroy this._fragment = null; this._state = {}; diff --git a/test/js/samples/if-block-no-update/expected.js b/test/js/samples/if-block-no-update/expected.js index 7010121fb5..1b6f454908 100644 --- a/test/js/samples/if-block-no-update/expected.js +++ b/test/js/samples/if-block-no-update/expected.js @@ -1,4 +1,4 @@ -import { appendNode, assign, createComment, createElement, createText, detachNode, dispatchObservers, insertNode, proto } from "svelte/shared.js"; +import { appendNode, assign, createComment, createElement, createText, detachNode, dispatchObservers, insertNode, noop, proto } from "svelte/shared.js"; function create_main_fragment ( state, component ) { function get_block ( state ) { @@ -19,18 +19,24 @@ function create_main_fragment ( state, component ) { update: function ( changed, state ) { if ( current_block !== ( current_block = get_block( state ) ) ) { - if_block.destroy( true ); + { + if_block.unmount(); + if_block.destroy(); + } if_block = current_block( state, component ); if_block.mount( if_block_anchor.parentNode, if_block_anchor ); } }, - destroy: function ( detach ) { - if_block.destroy( detach ); + unmount: function () { + detachNode( if_block_anchor ); + }, - if ( detach ) { - detachNode( if_block_anchor ); - } + destroy: function () { + { + if_block.unmount(); + if_block.destroy(); + } } }; } @@ -44,11 +50,11 @@ function create_if_block ( state, component ) { insertNode( p, target, anchor ); }, - destroy: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -61,11 +67,11 @@ function create_if_block_1 ( state, component ) { insertNode( p, target, anchor ); }, - destroy: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -102,7 +108,8 @@ SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.destroy( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy( false ); // TODO no arguments to destroy this._fragment = null; this._state = {}; diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js index 0998c38be3..e2e344ed84 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -1,3 +1,5 @@ +function noop () {} + function assign ( target ) { for ( var i = 1; i < arguments.length; i += 1 ) { var source = arguments[i]; @@ -144,17 +146,19 @@ function create_main_fragment ( state, component ) { if_block.mount( if_block_anchor.parentNode, if_block_anchor ); } } else if ( if_block ) { - if_block.destroy( true ); + if_block.unmount(); + if_block.destroy(); if_block = null; } }, - destroy: function ( detach ) { - if ( if_block ) if_block.destroy( detach ); + unmount: function () { + if ( if_block ) if_block.unmount(); + detachNode( if_block_anchor ); + }, - if ( detach ) { - detachNode( if_block_anchor ); - } + destroy: function () { + if ( if_block ) if_block.destroy(); } }; } @@ -168,11 +172,11 @@ function create_if_block ( state, component ) { insertNode( p, target, anchor ); }, - destroy: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -209,7 +213,8 @@ SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.destroy( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy( false ); // TODO no arguments to destroy this._fragment = null; this._state = {}; diff --git a/test/js/samples/if-block-simple/expected.js b/test/js/samples/if-block-simple/expected.js index b1fb14fa18..dd0d151c95 100644 --- a/test/js/samples/if-block-simple/expected.js +++ b/test/js/samples/if-block-simple/expected.js @@ -1,4 +1,4 @@ -import { appendNode, assign, createComment, createElement, createText, detachNode, dispatchObservers, insertNode, proto } from "svelte/shared.js"; +import { appendNode, assign, createComment, createElement, createText, detachNode, dispatchObservers, insertNode, noop, proto } from "svelte/shared.js"; function create_main_fragment ( state, component ) { var if_block = (state.foo) && create_if_block( state, component ); @@ -18,17 +18,19 @@ function create_main_fragment ( state, component ) { if_block.mount( if_block_anchor.parentNode, if_block_anchor ); } } else if ( if_block ) { - if_block.destroy( true ); + if_block.unmount(); + if_block.destroy(); if_block = null; } }, - destroy: function ( detach ) { - if ( if_block ) if_block.destroy( detach ); + unmount: function () { + if ( if_block ) if_block.unmount(); + detachNode( if_block_anchor ); + }, - if ( detach ) { - detachNode( if_block_anchor ); - } + destroy: function () { + if ( if_block ) if_block.destroy(); } }; } @@ -42,11 +44,11 @@ function create_if_block ( state, component ) { insertNode( p, target, anchor ); }, - destroy: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -83,7 +85,8 @@ SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.destroy( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy( false ); // TODO no arguments to destroy this._fragment = null; this._state = {}; diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index 3f8554332a..7d82f3f2be 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -144,13 +144,15 @@ function create_main_fragment ( state, component ) { nonimported._fragment.mount( target, anchor ); }, - destroy: function ( detach ) { - imported.destroy( detach ); - nonimported.destroy( detach ); + unmount: function () { + imported._fragment.unmount(); + detachNode( text ); + nonimported._fragment.unmount(); + }, - if ( detach ) { - detachNode( text ); - } + destroy: function () { + imported.destroy( false ); + nonimported.destroy( false ); } }; } @@ -190,7 +192,8 @@ SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.destroy( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy( false ); // TODO no arguments to destroy this._fragment = null; this._state = {}; diff --git a/test/js/samples/non-imported-component/expected.js b/test/js/samples/non-imported-component/expected.js index 602b33086e..acc10d855b 100644 --- a/test/js/samples/non-imported-component/expected.js +++ b/test/js/samples/non-imported-component/expected.js @@ -30,13 +30,15 @@ function create_main_fragment ( state, component ) { nonimported._fragment.mount( target, anchor ); }, - destroy: function ( detach ) { - imported.destroy( detach ); - nonimported.destroy( detach ); + unmount: function () { + imported._fragment.unmount(); + detachNode( text ); + nonimported._fragment.unmount(); + }, - if ( detach ) { - detachNode( text ); - } + destroy: function () { + imported.destroy( false ); + nonimported.destroy( false ); } }; } @@ -76,7 +78,8 @@ SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.destroy( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy( false ); // TODO no arguments to destroy this._fragment = null; this._state = {}; diff --git a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js index 424d82b761..ce0adb916d 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js @@ -118,6 +118,8 @@ function create_main_fragment ( state, component ) { return { mount: noop, + unmount: noop, + destroy: noop }; } @@ -161,7 +163,8 @@ SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = functio this.fire( 'destroy' ); template.ondestroy.call( this ); - this._fragment.destroy( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy( false ); // TODO no arguments to destroy this._fragment = null; this._state = {}; diff --git a/test/js/samples/onrender-onteardown-rewritten/expected.js b/test/js/samples/onrender-onteardown-rewritten/expected.js index 8e8f81e692..180b484c6a 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected.js @@ -14,6 +14,8 @@ function create_main_fragment ( state, component ) { return { mount: noop, + unmount: noop, + destroy: noop }; } @@ -57,7 +59,8 @@ SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = functio this.fire( 'destroy' ); template.ondestroy.call( this ); - this._fragment.destroy( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy( false ); // TODO no arguments to destroy this._fragment = null; this._state = {}; 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 4cc501c982..a723f7465b 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -1,3 +1,5 @@ +function noop () {} + function assign ( target ) { for ( var i = 1; i < arguments.length; i += 1 ) { var source = arguments[i]; @@ -181,7 +183,8 @@ function create_main_fragment ( state, component ) { if_block.mount( div, text ); } } else if ( if_block ) { - if_block.destroy( true ); + if_block.unmount(); + if_block.destroy(); if_block = null; } @@ -191,7 +194,8 @@ function create_main_fragment ( state, component ) { if_block_1.mount( div, text_3 ); } } else if ( if_block_1 ) { - if_block_1.destroy( true ); + if_block_1.unmount(); + if_block_1.destroy(); if_block_1 = null; } @@ -201,7 +205,8 @@ function create_main_fragment ( state, component ) { if_block_2.mount( div, text_4 ); } } else if ( if_block_2 ) { - if_block_2.destroy( true ); + if_block_2.unmount(); + if_block_2.destroy(); if_block_2 = null; } @@ -211,7 +216,8 @@ function create_main_fragment ( state, component ) { if_block_3.mount( div, text_7 ); } } else if ( if_block_3 ) { - if_block_3.destroy( true ); + if_block_3.unmount(); + if_block_3.destroy(); if_block_3 = null; } @@ -221,23 +227,29 @@ function create_main_fragment ( state, component ) { if_block_4.mount( if_block_4_anchor.parentNode, if_block_4_anchor ); } } else if ( if_block_4 ) { - if_block_4.destroy( true ); + if_block_4.unmount(); + if_block_4.destroy(); if_block_4 = null; } }, - destroy: function ( detach ) { - if ( if_block ) if_block.destroy( false ); - if ( if_block_1 ) if_block_1.destroy( false ); - if ( if_block_2 ) if_block_2.destroy( false ); - if ( if_block_3 ) if_block_3.destroy( false ); - if ( if_block_4 ) if_block_4.destroy( detach ); - - if ( detach ) { - detachNode( div ); - detachNode( text_8 ); - detachNode( if_block_4_anchor ); - } + unmount: function () { + detachNode( div ); + if ( if_block ) if_block.unmount(); + if ( if_block_1 ) if_block_1.unmount(); + if ( if_block_2 ) if_block_2.unmount(); + if ( if_block_3 ) if_block_3.unmount(); + detachNode( text_8 ); + if ( if_block_4 ) if_block_4.unmount(); + detachNode( if_block_4_anchor ); + }, + + destroy: function () { + if ( if_block ) if_block.destroy(); + if ( if_block_1 ) if_block_1.destroy(); + if ( if_block_2 ) if_block_2.destroy(); + if ( if_block_3 ) if_block_3.destroy(); + if ( if_block_4 ) if_block_4.destroy(); } }; } @@ -251,11 +263,11 @@ function create_if_block ( state, component ) { insertNode( p, target, anchor ); }, - destroy: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -268,11 +280,11 @@ function create_if_block_1 ( state, component ) { insertNode( p, target, anchor ); }, - destroy: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -285,11 +297,11 @@ function create_if_block_2 ( state, component ) { insertNode( p, target, anchor ); }, - destroy: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -302,11 +314,11 @@ function create_if_block_3 ( state, component ) { insertNode( p, target, anchor ); }, - destroy: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -319,11 +331,11 @@ function create_if_block_4 ( state, component ) { insertNode( p, target, anchor ); }, - destroy: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -360,7 +372,8 @@ SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.destroy( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy( false ); // TODO no arguments to destroy this._fragment = null; this._state = {}; diff --git a/test/js/samples/use-elements-as-anchors/expected.js b/test/js/samples/use-elements-as-anchors/expected.js index 0073faafd0..07f46a3eb1 100644 --- a/test/js/samples/use-elements-as-anchors/expected.js +++ b/test/js/samples/use-elements-as-anchors/expected.js @@ -1,4 +1,4 @@ -import { appendNode, assign, createComment, createElement, createText, detachNode, dispatchObservers, insertNode, proto } from "svelte/shared.js"; +import { appendNode, assign, createComment, createElement, createText, detachNode, dispatchObservers, insertNode, noop, proto } from "svelte/shared.js"; function create_main_fragment ( state, component ) { var div = createElement( 'div' ); @@ -55,7 +55,8 @@ function create_main_fragment ( state, component ) { if_block.mount( div, text ); } } else if ( if_block ) { - if_block.destroy( true ); + if_block.unmount(); + if_block.destroy(); if_block = null; } @@ -65,7 +66,8 @@ function create_main_fragment ( state, component ) { if_block_1.mount( div, text_3 ); } } else if ( if_block_1 ) { - if_block_1.destroy( true ); + if_block_1.unmount(); + if_block_1.destroy(); if_block_1 = null; } @@ -75,7 +77,8 @@ function create_main_fragment ( state, component ) { if_block_2.mount( div, text_4 ); } } else if ( if_block_2 ) { - if_block_2.destroy( true ); + if_block_2.unmount(); + if_block_2.destroy(); if_block_2 = null; } @@ -85,7 +88,8 @@ function create_main_fragment ( state, component ) { if_block_3.mount( div, text_7 ); } } else if ( if_block_3 ) { - if_block_3.destroy( true ); + if_block_3.unmount(); + if_block_3.destroy(); if_block_3 = null; } @@ -95,23 +99,29 @@ function create_main_fragment ( state, component ) { if_block_4.mount( if_block_4_anchor.parentNode, if_block_4_anchor ); } } else if ( if_block_4 ) { - if_block_4.destroy( true ); + if_block_4.unmount(); + if_block_4.destroy(); if_block_4 = null; } }, - destroy: function ( detach ) { - if ( if_block ) if_block.destroy( false ); - if ( if_block_1 ) if_block_1.destroy( false ); - if ( if_block_2 ) if_block_2.destroy( false ); - if ( if_block_3 ) if_block_3.destroy( false ); - if ( if_block_4 ) if_block_4.destroy( detach ); - - if ( detach ) { - detachNode( div ); - detachNode( text_8 ); - detachNode( if_block_4_anchor ); - } + unmount: function () { + detachNode( div ); + if ( if_block ) if_block.unmount(); + if ( if_block_1 ) if_block_1.unmount(); + if ( if_block_2 ) if_block_2.unmount(); + if ( if_block_3 ) if_block_3.unmount(); + detachNode( text_8 ); + if ( if_block_4 ) if_block_4.unmount(); + detachNode( if_block_4_anchor ); + }, + + destroy: function () { + if ( if_block ) if_block.destroy(); + if ( if_block_1 ) if_block_1.destroy(); + if ( if_block_2 ) if_block_2.destroy(); + if ( if_block_3 ) if_block_3.destroy(); + if ( if_block_4 ) if_block_4.destroy(); } }; } @@ -125,11 +135,11 @@ function create_if_block ( state, component ) { insertNode( p, target, anchor ); }, - destroy: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -142,11 +152,11 @@ function create_if_block_1 ( state, component ) { insertNode( p, target, anchor ); }, - destroy: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -159,11 +169,11 @@ function create_if_block_2 ( state, component ) { insertNode( p, target, anchor ); }, - destroy: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -176,11 +186,11 @@ function create_if_block_3 ( state, component ) { insertNode( p, target, anchor ); }, - destroy: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -193,11 +203,11 @@ function create_if_block_4 ( state, component ) { insertNode( p, target, anchor ); }, - destroy: function ( detach ) { - if ( detach ) { - detachNode( p ); - } - } + unmount: function () { + detachNode( p ); + }, + + destroy: noop }; } @@ -234,7 +244,8 @@ SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { this.fire( 'destroy' ); - this._fragment.destroy( detach !== false ); + if ( detach !== false ) this._fragment.unmount(); + this._fragment.destroy( false ); // TODO no arguments to destroy this._fragment = null; this._state = {};