From 7774c6d92a657d6b12e1b79ef6a04aa4435f27b9 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Mon, 9 Jul 2018 03:22:13 -0400 Subject: [PATCH 1/6] -> v2.9.2 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e494491c8..1e68a8c866 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Svelte changelog +## 2.9.2 + +* Fix conflict when using multiple if-else blocks, some of which use outros and some of which do not ([#1580](https://github.com/sveltejs/svelte/issues/1580)) +* Fix some cases where `.innerHTML` was being used to create child elements when it shouldn't ([#1581](https://github.com/sveltejs/svelte/issues/1581)) + ## 2.9.1 * Use `template.content` instead of `template` where appropriate ([#1571](https://github.com/sveltejs/svelte/issues/1571)) diff --git a/package.json b/package.json index e0c38b4038..84a8c07697 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "2.9.1", + "version": "2.9.2", "description": "The magical disappearing UI framework", "main": "compiler/svelte.js", "bin": { From e66d9ffae75928c8da96050b077385a343114a6c Mon Sep 17 00:00:00 2001 From: Conduitry Date: Mon, 9 Jul 2018 13:00:58 -0400 Subject: [PATCH 2/6] in .fire always set calling flag back to false (#1587) * in .fire always set calling flag back to false (#1573) * update expected bundles --- src/shared/index.js | 9 +++++--- test/cli/samples/basic/expected/Main.js | 9 +++++--- .../samples/custom-element/expected/Main.js | 9 +++++--- test/cli/samples/dev/expected/Main.js | 9 +++++--- .../samples/dir-sourcemap/expected/Main.js | 11 +++++---- .../dir-sourcemap/expected/Main.js.map | 2 +- .../samples/dir-sourcemap/expected/Widget.js | 11 +++++---- .../dir-sourcemap/expected/Widget.js.map | 2 +- test/cli/samples/dir-subdir/expected/Main.js | 9 +++++--- .../dir-subdir/expected/widget/Widget.js | 9 +++++--- test/cli/samples/dir/expected/Main.js | 9 +++++--- test/cli/samples/dir/expected/Widget.js | 9 +++++--- test/cli/samples/globals/expected/Main.js | 9 +++++--- .../samples/sourcemap-inline/expected/Main.js | 11 +++++---- test/cli/samples/sourcemap/expected/Main.js | 9 +++++--- .../samples/sourcemap/expected/Main.js.map | 2 +- test/cli/samples/store/expected/Main.js | 9 +++++--- test/js/samples/action/expected-bundle.js | 9 +++++--- .../bind-width-height/expected-bundle.js | 9 +++++--- .../expected-bundle.js | 9 +++++--- .../component-static-array/expected-bundle.js | 9 +++++--- .../expected-bundle.js | 9 +++++--- .../expected-bundle.js | 9 +++++--- .../component-static/expected-bundle.js | 9 +++++--- .../computed-collapsed-if/expected-bundle.js | 9 +++++--- .../css-media-query/expected-bundle.js | 9 +++++--- .../expected-bundle.js | 9 +++++--- .../deconflict-builtins/expected-bundle.js | 9 +++++--- .../deconflict-globals/expected-bundle.js | 9 +++++--- .../expected-bundle.js | 9 +++++--- .../samples/do-use-dataset/expected-bundle.js | 9 +++++--- .../expected-bundle.js | 9 +++++--- .../expected-bundle.js | 9 +++++--- .../expected-bundle.js | 9 +++++--- .../expected-bundle.js | 9 +++++--- .../each-block-keyed/expected-bundle.js | 9 +++++--- .../event-handlers-custom/expected-bundle.js | 9 +++++--- .../head-no-whitespace/expected-bundle.js | 9 +++++--- .../if-block-no-update/expected-bundle.js | 9 +++++--- .../if-block-simple/expected-bundle.js | 9 +++++--- .../expected-bundle.js | 9 +++++--- .../expected-bundle.js | 9 +++++--- .../inline-style-optimized/expected-bundle.js | 9 +++++--- .../expected-bundle.js | 9 +++++--- .../js/samples/input-range/expected-bundle.js | 9 +++++--- .../expected-bundle.js | 9 +++++--- .../legacy-input-type/expected-bundle.js | 9 +++++--- .../samples/media-bindings/expected-bundle.js | 9 +++++--- .../non-imported-component/expected-bundle.js | 9 +++++--- .../samples/setup-method/expected-bundle.js | 9 +++++--- test/js/samples/svg-title/expected-bundle.js | 9 +++++--- test/js/samples/title/expected-bundle.js | 9 +++++--- .../expected-bundle.js | 9 +++++--- .../window-binding-scroll/expected-bundle.js | 9 +++++--- .../component-events-fire-finally/_config.js | 23 +++++++++++++++++++ .../component-events-fire-finally/main.html | 1 + 56 files changed, 336 insertions(+), 159 deletions(-) create mode 100644 test/runtime/samples/component-events-fire-finally/_config.js create mode 100644 test/runtime/samples/component-events-fire-finally/main.html diff --git a/src/shared/index.js b/src/shared/index.js index 4d0e7896c6..e4c71046e3 100644 --- a/src/shared/index.js +++ b/src/shared/index.js @@ -47,9 +47,12 @@ export function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/cli/samples/basic/expected/Main.js b/test/cli/samples/basic/expected/Main.js index 19de3981da..920f6a2f44 100644 --- a/test/cli/samples/basic/expected/Main.js +++ b/test/cli/samples/basic/expected/Main.js @@ -100,9 +100,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/cli/samples/custom-element/expected/Main.js b/test/cli/samples/custom-element/expected/Main.js index 64981ea826..659e76fbca 100644 --- a/test/cli/samples/custom-element/expected/Main.js +++ b/test/cli/samples/custom-element/expected/Main.js @@ -121,9 +121,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/cli/samples/dev/expected/Main.js b/test/cli/samples/dev/expected/Main.js index 3808927235..38d5f44d11 100644 --- a/test/cli/samples/dev/expected/Main.js +++ b/test/cli/samples/dev/expected/Main.js @@ -121,9 +121,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/cli/samples/dir-sourcemap/expected/Main.js b/test/cli/samples/dir-sourcemap/expected/Main.js index 85e8e85480..31c1929c53 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.7.2 */ +/* src/Main.html generated by Svelte vx.y.z */ import Widget from './Widget.html'; @@ -108,9 +108,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/cli/samples/dir-sourcemap/expected/Main.js.map b/test/cli/samples/dir-sourcemap/expected/Main.js.map index 3177f8b8be..7c0c800ddb 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 47794ea409..786784b6fa 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.7.2 */ +/* src/Widget.html generated by Svelte vx.y.z */ function create_main_fragment(component, ctx) { var p; @@ -100,9 +100,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/cli/samples/dir-sourcemap/expected/Widget.js.map b/test/cli/samples/dir-sourcemap/expected/Widget.js.map index 1fb22cb1e4..3fcdc995a4 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 a80bf2f976..2e908cfa44 100644 --- a/test/cli/samples/dir-subdir/expected/Main.js +++ b/test/cli/samples/dir-subdir/expected/Main.js @@ -108,9 +108,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/cli/samples/dir-subdir/expected/widget/Widget.js b/test/cli/samples/dir-subdir/expected/widget/Widget.js index 974326ad95..f192602d16 100644 --- a/test/cli/samples/dir-subdir/expected/widget/Widget.js +++ b/test/cli/samples/dir-subdir/expected/widget/Widget.js @@ -100,9 +100,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/cli/samples/dir/expected/Main.js b/test/cli/samples/dir/expected/Main.js index edfbe3c67f..9a9d8e38fe 100644 --- a/test/cli/samples/dir/expected/Main.js +++ b/test/cli/samples/dir/expected/Main.js @@ -108,9 +108,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/cli/samples/dir/expected/Widget.js b/test/cli/samples/dir/expected/Widget.js index 7bec9ae438..41e573ce5e 100644 --- a/test/cli/samples/dir/expected/Widget.js +++ b/test/cli/samples/dir/expected/Widget.js @@ -100,9 +100,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/cli/samples/globals/expected/Main.js b/test/cli/samples/globals/expected/Main.js index 1a79813b58..3b1a574c2a 100644 --- a/test/cli/samples/globals/expected/Main.js +++ b/test/cli/samples/globals/expected/Main.js @@ -121,9 +121,12 @@ var Main = (function(answer) { "use strict"; var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/cli/samples/sourcemap-inline/expected/Main.js b/test/cli/samples/sourcemap-inline/expected/Main.js index de6a8894ce..010be62a1b 100644 --- a/test/cli/samples/sourcemap-inline/expected/Main.js +++ b/test/cli/samples/sourcemap-inline/expected/Main.js @@ -100,9 +100,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } @@ -166,4 +169,4 @@ function callAll(fns) { while (fns && fns.length) fns.shift()(); } export default Main; -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWFpbi5qcyIsInNvdXJjZXMiOlsiLi4vc3JjL01haW4uaHRtbCJdLCJzb3VyY2VzQ29udGVudCI6WyI8cD5IZWxsbyB3b3JsZCE8L3A+XG5cbjxzY3JpcHQ+XG5cdGV4cG9ydCBkZWZhdWx0IHtcblx0XHRvbnJlbmRlciAoKSB7XG5cdFx0XHRjb25zb2xlLmxvZyggJ2hlcmUnICk7XG5cdFx0fVxuXHR9O1xuPC9zY3JpcHQ+Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWFpbi5qcyIsInNvdXJjZXMiOlsiLi4vc3JjL01haW4uaHRtbCJdLCJzb3VyY2VzQ29udGVudCI6WyI8cD5IZWxsbyB3b3JsZCE8L3A+XG5cbjxzY3JpcHQ+XG5cdGV4cG9ydCBkZWZhdWx0IHtcblx0XHRvbnJlbmRlciAoKSB7XG5cdFx0XHRjb25zb2xlLmxvZyggJ2hlcmUnICk7XG5cdFx0fVxuXHR9O1xuPC9zY3JpcHQ+Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9 diff --git a/test/cli/samples/sourcemap/expected/Main.js b/test/cli/samples/sourcemap/expected/Main.js index e136e16f48..49f6094890 100644 --- a/test/cli/samples/sourcemap/expected/Main.js +++ b/test/cli/samples/sourcemap/expected/Main.js @@ -100,9 +100,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/cli/samples/sourcemap/expected/Main.js.map b/test/cli/samples/sourcemap/expected/Main.js.map index e5a7f2a162..eab12a290f 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 3f97badad4..85e3e790b3 100644 --- a/test/cli/samples/store/expected/Main.js +++ b/test/cli/samples/store/expected/Main.js @@ -120,9 +120,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/action/expected-bundle.js b/test/js/samples/action/expected-bundle.js index e1b3e6ce18..f47b987f6e 100644 --- a/test/js/samples/action/expected-bundle.js +++ b/test/js/samples/action/expected-bundle.js @@ -44,9 +44,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/bind-width-height/expected-bundle.js b/test/js/samples/bind-width-height/expected-bundle.js index 8a441a8d3f..71a406956c 100644 --- a/test/js/samples/bind-width-height/expected-bundle.js +++ b/test/js/samples/bind-width-height/expected-bundle.js @@ -76,9 +76,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } 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 87f65ba860..f9438487ae 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -52,9 +52,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/component-static-array/expected-bundle.js b/test/js/samples/component-static-array/expected-bundle.js index 5f85c7487a..30534f977e 100644 --- a/test/js/samples/component-static-array/expected-bundle.js +++ b/test/js/samples/component-static-array/expected-bundle.js @@ -32,9 +32,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/component-static-immutable/expected-bundle.js b/test/js/samples/component-static-immutable/expected-bundle.js index 3ebd360b2a..de9fc1a4a2 100644 --- a/test/js/samples/component-static-immutable/expected-bundle.js +++ b/test/js/samples/component-static-immutable/expected-bundle.js @@ -36,9 +36,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/component-static-immutable2/expected-bundle.js b/test/js/samples/component-static-immutable2/expected-bundle.js index 3ebd360b2a..de9fc1a4a2 100644 --- a/test/js/samples/component-static-immutable2/expected-bundle.js +++ b/test/js/samples/component-static-immutable2/expected-bundle.js @@ -36,9 +36,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/component-static/expected-bundle.js b/test/js/samples/component-static/expected-bundle.js index d2c8280062..af59f9e893 100644 --- a/test/js/samples/component-static/expected-bundle.js +++ b/test/js/samples/component-static/expected-bundle.js @@ -32,9 +32,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index 73830ee233..a2ba378a2a 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -32,9 +32,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js index ff7bdcfcc1..aa5d7f27e8 100644 --- a/test/js/samples/css-media-query/expected-bundle.js +++ b/test/js/samples/css-media-query/expected-bundle.js @@ -48,9 +48,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } 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 8d9d31dff2..d2a6b25d7b 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js @@ -44,9 +44,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/deconflict-builtins/expected-bundle.js b/test/js/samples/deconflict-builtins/expected-bundle.js index c3d9d762b9..5be78115b9 100644 --- a/test/js/samples/deconflict-builtins/expected-bundle.js +++ b/test/js/samples/deconflict-builtins/expected-bundle.js @@ -62,9 +62,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/deconflict-globals/expected-bundle.js b/test/js/samples/deconflict-globals/expected-bundle.js index 0d2226d5cb..45e4bed141 100644 --- a/test/js/samples/deconflict-globals/expected-bundle.js +++ b/test/js/samples/deconflict-globals/expected-bundle.js @@ -37,9 +37,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } 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 3b9a92c90e..7df754d670 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 @@ -65,9 +65,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/do-use-dataset/expected-bundle.js b/test/js/samples/do-use-dataset/expected-bundle.js index 10c7600975..04c620a5af 100644 --- a/test/js/samples/do-use-dataset/expected-bundle.js +++ b/test/js/samples/do-use-dataset/expected-bundle.js @@ -48,9 +48,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } 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 4a963e3300..d06c76d74f 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 @@ -52,9 +52,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } 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 5b1827344d..5f5f0b5e50 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 @@ -52,9 +52,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } 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 02db1ce829..1eb4cd25b1 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -64,9 +64,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/each-block-keyed-animated/expected-bundle.js b/test/js/samples/each-block-keyed-animated/expected-bundle.js index b1ecb4ce56..9bf521964c 100644 --- a/test/js/samples/each-block-keyed-animated/expected-bundle.js +++ b/test/js/samples/each-block-keyed-animated/expected-bundle.js @@ -367,9 +367,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/each-block-keyed/expected-bundle.js b/test/js/samples/each-block-keyed/expected-bundle.js index 09f61a6d3e..51978b8df5 100644 --- a/test/js/samples/each-block-keyed/expected-bundle.js +++ b/test/js/samples/each-block-keyed/expected-bundle.js @@ -147,9 +147,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index 78d5d1a005..e254bd203b 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -44,9 +44,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/head-no-whitespace/expected-bundle.js b/test/js/samples/head-no-whitespace/expected-bundle.js index d878a85cbf..66af456722 100644 --- a/test/js/samples/head-no-whitespace/expected-bundle.js +++ b/test/js/samples/head-no-whitespace/expected-bundle.js @@ -44,9 +44,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } 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 f07810c565..0b936db262 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -48,9 +48,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js index 88729b1159..e2034c1527 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -48,9 +48,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } 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 37dd300b5d..b65fd4ec2f 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js @@ -48,9 +48,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } 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 716dac771d..908b20e948 100644 --- a/test/js/samples/inline-style-optimized-url/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-url/expected-bundle.js @@ -48,9 +48,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/inline-style-optimized/expected-bundle.js b/test/js/samples/inline-style-optimized/expected-bundle.js index 817462d0bd..fec142ef75 100644 --- a/test/js/samples/inline-style-optimized/expected-bundle.js +++ b/test/js/samples/inline-style-optimized/expected-bundle.js @@ -48,9 +48,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/inline-style-unoptimized/expected-bundle.js b/test/js/samples/inline-style-unoptimized/expected-bundle.js index a378c2f4a6..93993ce8df 100644 --- a/test/js/samples/inline-style-unoptimized/expected-bundle.js +++ b/test/js/samples/inline-style-unoptimized/expected-bundle.js @@ -48,9 +48,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/input-range/expected-bundle.js b/test/js/samples/input-range/expected-bundle.js index 108fc37a01..50ba725fa9 100644 --- a/test/js/samples/input-range/expected-bundle.js +++ b/test/js/samples/input-range/expected-bundle.js @@ -60,9 +60,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } 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 e3fb0c60a4..5bf43ec519 100644 --- a/test/js/samples/input-without-blowback-guard/expected-bundle.js +++ b/test/js/samples/input-without-blowback-guard/expected-bundle.js @@ -56,9 +56,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/legacy-input-type/expected-bundle.js b/test/js/samples/legacy-input-type/expected-bundle.js index e1d6f84a8f..55cbf0425c 100644 --- a/test/js/samples/legacy-input-type/expected-bundle.js +++ b/test/js/samples/legacy-input-type/expected-bundle.js @@ -50,9 +50,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/media-bindings/expected-bundle.js b/test/js/samples/media-bindings/expected-bundle.js index fd83ed3c68..ec9116f544 100644 --- a/test/js/samples/media-bindings/expected-bundle.js +++ b/test/js/samples/media-bindings/expected-bundle.js @@ -60,9 +60,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index 345d98d16e..45134a785a 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -46,9 +46,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js index df0ea63860..5781b383a1 100644 --- a/test/js/samples/setup-method/expected-bundle.js +++ b/test/js/samples/setup-method/expected-bundle.js @@ -32,9 +32,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/svg-title/expected-bundle.js b/test/js/samples/svg-title/expected-bundle.js index 4073da0148..ab950e54a5 100644 --- a/test/js/samples/svg-title/expected-bundle.js +++ b/test/js/samples/svg-title/expected-bundle.js @@ -52,9 +52,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/title/expected-bundle.js b/test/js/samples/title/expected-bundle.js index 109ec3276b..e994b9fdfc 100644 --- a/test/js/samples/title/expected-bundle.js +++ b/test/js/samples/title/expected-bundle.js @@ -32,9 +32,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } 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 2771ac3719..f0df077bfa 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -56,9 +56,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/js/samples/window-binding-scroll/expected-bundle.js b/test/js/samples/window-binding-scroll/expected-bundle.js index 2d718e483f..64d397a982 100644 --- a/test/js/samples/window-binding-scroll/expected-bundle.js +++ b/test/js/samples/window-binding-scroll/expected-bundle.js @@ -52,9 +52,12 @@ function fire(eventName, data) { var handler = handlers[i]; if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; + try { + handler.__calling = true; + handler.call(this, data); + } finally { + handler.__calling = false; + } } } } diff --git a/test/runtime/samples/component-events-fire-finally/_config.js b/test/runtime/samples/component-events-fire-finally/_config.js new file mode 100644 index 0000000000..f768f5608b --- /dev/null +++ b/test/runtime/samples/component-events-fire-finally/_config.js @@ -0,0 +1,23 @@ +export default { + test(assert, component) { + const events = []; + component.on('foo', (shouldThrow) => { + events.push(shouldThrow); + if (shouldThrow) { + throw new Error(); + } + }); + component.fire('foo', false); + assert.equal(events.toString(), 'false'); + let threw = false; + try { + component.fire('foo', true); + } catch (err) { + threw = true; + } + assert.equal(threw, true); + assert.equal(events.toString(), 'false,true'); + component.fire('foo', false); + assert.equal(events.toString(), 'false,true,false'); + }, +}; diff --git a/test/runtime/samples/component-events-fire-finally/main.html b/test/runtime/samples/component-events-fire-finally/main.html new file mode 100644 index 0000000000..bc56c4d894 --- /dev/null +++ b/test/runtime/samples/component-events-fire-finally/main.html @@ -0,0 +1 @@ +Foo From 26dfb9afa73c5fd564bbd5efbfc6155a0e9930e9 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Mon, 9 Jul 2018 13:02:17 -0400 Subject: [PATCH 3/6] in each-else, use mount/intro according to that branch's contents (#1586) Fixes # 1559 --- src/compile/nodes/EachBlock.ts | 1 + src/compile/nodes/ElseBlock.ts | 1 + .../samples/each-block-else-mount-or-intro/Widget.html | 1 + .../samples/each-block-else-mount-or-intro/_config.js | 5 +++++ .../samples/each-block-else-mount-or-intro/main.html | 9 +++++++++ 5 files changed, 17 insertions(+) create mode 100644 test/runtime/samples/each-block-else-mount-or-intro/Widget.html create mode 100644 test/runtime/samples/each-block-else-mount-or-intro/_config.js create mode 100644 test/runtime/samples/each-block-else-mount-or-intro/main.html diff --git a/src/compile/nodes/EachBlock.ts b/src/compile/nodes/EachBlock.ts index a29877367e..cae0aa7352 100644 --- a/src/compile/nodes/EachBlock.ts +++ b/src/compile/nodes/EachBlock.ts @@ -189,6 +189,7 @@ export default class EachBlock extends Node { if (this.else) { const each_block_else = compiler.getUniqueName(`${each}_else`); + const mountOrIntro = (this.else.block.hasIntroMethod || this.else.block.hasOutroMethod) ? 'i' : 'm'; block.builders.init.addLine(`var ${each_block_else} = null;`); diff --git a/src/compile/nodes/ElseBlock.ts b/src/compile/nodes/ElseBlock.ts index 742fbc7f91..7d334e3356 100644 --- a/src/compile/nodes/ElseBlock.ts +++ b/src/compile/nodes/ElseBlock.ts @@ -5,6 +5,7 @@ import mapChildren from './shared/mapChildren'; export default class ElseBlock extends Node { type: 'ElseBlock'; children: Node[]; + block: Block; constructor(compiler, parent, scope, info) { super(compiler, parent, scope, info); diff --git a/test/runtime/samples/each-block-else-mount-or-intro/Widget.html b/test/runtime/samples/each-block-else-mount-or-intro/Widget.html new file mode 100644 index 0000000000..bc56c4d894 --- /dev/null +++ b/test/runtime/samples/each-block-else-mount-or-intro/Widget.html @@ -0,0 +1 @@ +Foo diff --git a/test/runtime/samples/each-block-else-mount-or-intro/_config.js b/test/runtime/samples/each-block-else-mount-or-intro/_config.js new file mode 100644 index 0000000000..0880b896c2 --- /dev/null +++ b/test/runtime/samples/each-block-else-mount-or-intro/_config.js @@ -0,0 +1,5 @@ +export default { + nestedTransitions: true, + data: { items: [] }, + html: `No items.`, +}; diff --git a/test/runtime/samples/each-block-else-mount-or-intro/main.html b/test/runtime/samples/each-block-else-mount-or-intro/main.html new file mode 100644 index 0000000000..4604ecd788 --- /dev/null +++ b/test/runtime/samples/each-block-else-mount-or-intro/main.html @@ -0,0 +1,9 @@ +{#each items as item} + +{:else} + No items. +{/each} + + From 557e7b7ccba46cf9761190f870df4ed57f2d1223 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Mon, 9 Jul 2018 13:09:12 -0400 Subject: [PATCH 4/6] -> v2.9.3 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e68a8c866..0919dc7118 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Svelte changelog +## v2.9.3 + +* Fix bug when an each block contains transitions but its else branch does not ([#1559](https://github.com/sveltejs/svelte/issues/1559)) +* If an event handler throws an exception, don't block all future calls to that handler ([#1573](https://github.com/sveltejs/svelte/issues/1573)) + ## 2.9.2 * Fix conflict when using multiple if-else blocks, some of which use outros and some of which do not ([#1580](https://github.com/sveltejs/svelte/issues/1580)) diff --git a/package.json b/package.json index 84a8c07697..c72d0f795a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "2.9.2", + "version": "2.9.3", "description": "The magical disappearing UI framework", "main": "compiler/svelte.js", "bin": { From b4d7653b42971c281e2a0059829f6fbc66ebd7ce Mon Sep 17 00:00:00 2001 From: Conduitry Date: Mon, 9 Jul 2018 20:10:28 -0400 Subject: [PATCH 5/6] allow {:then}/{:catch} to have no bound identifier (#1507) --- src/parse/state/mustache.ts | 22 +++++----- .../await-then-catch-no-values/_config.js | 41 +++++++++++++++++++ .../await-then-catch-no-values/main.html | 7 ++++ 3 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 test/runtime/samples/await-then-catch-no-values/_config.js create mode 100644 test/runtime/samples/await-then-catch-no-values/main.html diff --git a/src/parse/state/mustache.ts b/src/parse/state/mustache.ts index 657aceac65..cbac76e6a1 100644 --- a/src/parse/state/mustache.ts +++ b/src/parse/state/mustache.ts @@ -147,11 +147,12 @@ export default function mustache(parser: Parser) { parser.stack.pop(); const awaitBlock = parser.current(); - parser.requireWhitespace(); - awaitBlock.value = parser.readIdentifier(); - - parser.allowWhitespace(); - parser.eat('}', true); + if (!parser.eat('}')) { + parser.requireWhitespace(); + awaitBlock.value = parser.readIdentifier(); + parser.allowWhitespace(); + parser.eat('}', true); + } const thenBlock: Node = { start, @@ -170,11 +171,12 @@ export default function mustache(parser: Parser) { parser.stack.pop(); const awaitBlock = parser.current(); - parser.requireWhitespace(); - awaitBlock.error = parser.readIdentifier(); - - parser.allowWhitespace(); - parser.eat('}', true); + if (!parser.eat('}')) { + parser.requireWhitespace(); + awaitBlock.error = parser.readIdentifier(); + parser.allowWhitespace(); + parser.eat('}', true); + } const catchBlock: Node = { start, diff --git a/test/runtime/samples/await-then-catch-no-values/_config.js b/test/runtime/samples/await-then-catch-no-values/_config.js new file mode 100644 index 0000000000..88e38784a3 --- /dev/null +++ b/test/runtime/samples/await-then-catch-no-values/_config.js @@ -0,0 +1,41 @@ +let fulfil; + +let thePromise = new Promise(f => { + fulfil = f; +}); + +export default { + data: { + thePromise + }, + + html: `waiting`, + + test(assert, component, target) { + fulfil(9000); + + return thePromise + .then(() => { + assert.htmlEqual(target.innerHTML, `resolved`); + + let reject; + + thePromise = new Promise((f, r) => { + reject = r; + }); + + component.set({ + thePromise + }); + + assert.htmlEqual(target.innerHTML, `waiting`); + + reject(new Error('something broke')); + + return thePromise.catch(() => {}); + }) + .then(() => { + assert.htmlEqual(target.innerHTML, `rejected`); + }); + } +}; diff --git a/test/runtime/samples/await-then-catch-no-values/main.html b/test/runtime/samples/await-then-catch-no-values/main.html new file mode 100644 index 0000000000..414b2fd068 --- /dev/null +++ b/test/runtime/samples/await-then-catch-no-values/main.html @@ -0,0 +1,7 @@ +{#await thePromise} + waiting +{:then} + resolved +{:catch} + rejected +{/await} From de1edddf0e15ca577be95b635c0a1f937c7f0d34 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Tue, 10 Jul 2018 21:46:25 -0400 Subject: [PATCH 6/6] tidying --- src/compile/nodes/IfBlock.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/compile/nodes/IfBlock.ts b/src/compile/nodes/IfBlock.ts index 23ac29166e..4852950429 100644 --- a/src/compile/nodes/IfBlock.ts +++ b/src/compile/nodes/IfBlock.ts @@ -208,14 +208,7 @@ export default class IfBlock extends Node { const updateMountNode = this.getUpdateMountNode(anchor); const changeBlock = deindent` - ${hasElse - ? deindent` - ${name}.d(1); - ` - : deindent` - if (${name}) { - ${name}.d(1); - }`} + ${if_name}${name}.d(1); ${name} = ${current_block_type_and}${current_block_type}(#component, ctx); ${if_name}${name}.c(); ${if_name}${name}.${mountOrIntro}(${updateMountNode}, ${anchor});