From 15299e7be0f6bcb4c9848e10f8e3da949c869317 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Mon, 9 Jul 2018 13:00:58 -0400 Subject: [PATCH] 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