From 44b73191c70712079882df2ead9800712aa514ef Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 5 Aug 2017 22:24:31 -0400 Subject: [PATCH] update tests --- src/shared/index.js | 1 + .../samples/collapses-text-around-comments/expected-bundle.js | 2 +- test/js/samples/computed-collapsed-if/expected-bundle.js | 2 +- test/js/samples/css-media-query/expected-bundle.js | 2 +- test/js/samples/each-block-changed-check/expected-bundle.js | 2 +- test/js/samples/event-handlers-custom/expected-bundle.js | 4 +++- test/js/samples/if-block-no-update/expected-bundle.js | 2 +- test/js/samples/if-block-simple/expected-bundle.js | 2 +- test/js/samples/non-imported-component/expected-bundle.js | 4 +++- .../samples/onrender-onteardown-rewritten/expected-bundle.js | 4 ++-- test/js/samples/onrender-onteardown-rewritten/expected.js | 2 +- test/js/samples/setup-method/expected-bundle.js | 2 +- test/js/samples/use-elements-as-anchors/expected-bundle.js | 2 +- 13 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/shared/index.js b/src/shared/index.js index 7e4afb7dfe..67aa972f6f 100644 --- a/src/shared/index.js +++ b/src/shared/index.js @@ -1,4 +1,5 @@ import { assign } from './utils.js'; +import { noop } from './utils.js'; export * from './dom.js'; export * from './transitions.js'; export * from './utils.js'; 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 053e4c2c12..93e2086a26 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -39,6 +39,7 @@ function setAttribute(node, attribute, value) { function destroy(detach) { if (!this._destroyed) { + this.set = noop; this.fire('destroy'); if (detach !== false) this._fragment.unmount(); @@ -127,7 +128,6 @@ function on(eventName, handler) { } function set(newState) { - if (this._destroyed) return; this._set(assign({}, newState)); if (this._root._lock) return; this._root._lock = true; diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index a52a992476..b0d7198a01 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -15,6 +15,7 @@ function assign(target) { function destroy(detach) { if (!this._destroyed) { + this.set = noop; this.fire('destroy'); if (detach !== false) this._fragment.unmount(); @@ -103,7 +104,6 @@ function on(eventName, handler) { } function set(newState) { - if (this._destroyed) return; this._set(assign({}, newState)); if (this._root._lock) return; this._root._lock = true; diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js index 8ecdac50c1..b2ddda972b 100644 --- a/test/js/samples/css-media-query/expected-bundle.js +++ b/test/js/samples/css-media-query/expected-bundle.js @@ -35,6 +35,7 @@ function setAttribute(node, attribute, value) { function destroy(detach) { if (!this._destroyed) { + this.set = noop; this.fire('destroy'); if (detach !== false) this._fragment.unmount(); @@ -123,7 +124,6 @@ function on(eventName, handler) { } function set(newState) { - if (this._destroyed) return; this._set(assign({}, newState)); if (this._root._lock) return; this._root._lock = true; 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 f77ab22f89..823ff6e216 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -48,6 +48,7 @@ function createText(data) { function destroy(detach) { if (!this._destroyed) { + this.set = noop; this.fire('destroy'); if (detach !== false) this._fragment.unmount(); @@ -136,7 +137,6 @@ function on(eventName, handler) { } function set(newState) { - if (this._destroyed) return; this._set(assign({}, newState)); if (this._root._lock) return; this._root._lock = true; diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index 12857effdd..5f26fec2c6 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -1,3 +1,5 @@ +function noop() {} + function assign(target) { var k, source, @@ -33,6 +35,7 @@ function createText(data) { function destroy(detach) { if (!this._destroyed) { + this.set = noop; this.fire('destroy'); if (detach !== false) this._fragment.unmount(); @@ -121,7 +124,6 @@ function on(eventName, handler) { } function set(newState) { - if (this._destroyed) return; this._set(assign({}, newState)); if (this._root._lock) return; this._root._lock = true; 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 56ab031da3..2cbbc1ac22 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -39,6 +39,7 @@ function createComment() { function destroy(detach) { if (!this._destroyed) { + this.set = noop; this.fire('destroy'); if (detach !== false) this._fragment.unmount(); @@ -127,7 +128,6 @@ function on(eventName, handler) { } function set(newState) { - if (this._destroyed) return; this._set(assign({}, newState)); if (this._root._lock) return; this._root._lock = true; diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js index aca06df4f4..a311445c9d 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -39,6 +39,7 @@ function createComment() { function destroy(detach) { if (!this._destroyed) { + this.set = noop; this.fire('destroy'); if (detach !== false) this._fragment.unmount(); @@ -127,7 +128,6 @@ function on(eventName, handler) { } function set(newState) { - if (this._destroyed) return; this._set(assign({}, newState)); if (this._root._lock) return; this._root._lock = true; diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index e9a1ef969d..448fcbb3f6 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -1,5 +1,7 @@ import Imported from 'Imported.html'; +function noop() {} + function assign(target) { var k, source, @@ -27,6 +29,7 @@ function createText(data) { function destroy(detach) { if (!this._destroyed) { + this.set = noop; this.fire('destroy'); if (detach !== false) this._fragment.unmount(); @@ -115,7 +118,6 @@ function on(eventName, handler) { } function set(newState) { - if (this._destroyed) return; this._set(assign({}, newState)); if (this._root._lock) return; this._root._lock = true; diff --git a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js index 041326fdf3..f79163ae3e 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js @@ -15,6 +15,7 @@ function assign(target) { function destroy(detach) { if (!this._destroyed) { + this.set = noop; this.fire('destroy'); if (detach !== false) this._fragment.unmount(); @@ -103,7 +104,6 @@ function on(eventName, handler) { } function set(newState) { - if (this._destroyed) return; this._set(assign({}, newState)); if (this._root._lock) return; this._root._lock = true; @@ -158,7 +158,7 @@ function SvelteComponent ( options ) { }; this._handlers = Object.create( null ); - this._handlers.destroy = [template.ondestroy.bind(this)]; + this._handlers.destroy = [template.ondestroy]; this._root = options._root || this; this._yield = options._yield; diff --git a/test/js/samples/onrender-onteardown-rewritten/expected.js b/test/js/samples/onrender-onteardown-rewritten/expected.js index f40d3e0a5c..78c1a7e480 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected.js @@ -31,7 +31,7 @@ function SvelteComponent ( options ) { }; this._handlers = Object.create( null ); - this._handlers.destroy = [template.ondestroy.bind(this)] + this._handlers.destroy = [template.ondestroy] this._root = options._root || this; this._yield = options._yield; diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js index d27a1ef958..c4a3c6178e 100644 --- a/test/js/samples/setup-method/expected-bundle.js +++ b/test/js/samples/setup-method/expected-bundle.js @@ -15,6 +15,7 @@ function assign(target) { function destroy(detach) { if (!this._destroyed) { + this.set = noop; this.fire('destroy'); if (detach !== false) this._fragment.unmount(); @@ -103,7 +104,6 @@ function on(eventName, handler) { } function set(newState) { - if (this._destroyed) return; this._set(assign({}, newState)); if (this._root._lock) return; this._root._lock = true; 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 dd1ed072bb..04890dcc7e 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -39,6 +39,7 @@ function createComment() { function destroy(detach) { if (!this._destroyed) { + this.set = noop; this.fire('destroy'); if (detach !== false) this._fragment.unmount(); @@ -127,7 +128,6 @@ function on(eventName, handler) { } function set(newState) { - if (this._destroyed) return; this._set(assign({}, newState)); if (this._root._lock) return; this._root._lock = true;