diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts index bab3466c0b..678f79f3c9 100644 --- a/src/compiler/compile/Component.ts +++ b/src/compiler/compile/Component.ts @@ -947,8 +947,8 @@ export default class Component { const top_level_function_declarations = new Map(); const { body } = this.ast.instance.content; - let i = body.length; - while (i--) { + + for (let i = 0; i < body.length; i += 1) { const node = body[i]; if (node.type === 'VariableDeclaration') { @@ -981,7 +981,7 @@ export default class Component { hoistable_nodes.add(node); - body.splice(i, 1); + body.splice(i--, 1); this.fully_hoisted.push(node); } } diff --git a/test/js/samples/action-custom-event-handler/expected.js b/test/js/samples/action-custom-event-handler/expected.js index ec65b83cd2..c54ad93202 100644 --- a/test/js/samples/action-custom-event-handler/expected.js +++ b/test/js/samples/action-custom-event-handler/expected.js @@ -34,14 +34,14 @@ function create_fragment(ctx) { }; } -function foo(node, callback) { - -} - function handleFoo(bar) { console.log(bar); } +function foo(node, callback) { + +} + function instance($$self, $$props, $$invalidate) { let { bar } = $$props; const foo_function = () => handleFoo(bar); diff --git a/test/js/samples/dynamic-import/expected.js b/test/js/samples/dynamic-import/expected.js index 948cf183e1..50172bcb40 100644 --- a/test/js/samples/dynamic-import/expected.js +++ b/test/js/samples/dynamic-import/expected.js @@ -8,6 +8,7 @@ import { transition_in, transition_out } from "svelte/internal"; + import LazyLoad from "./LazyLoad.svelte"; function create_fragment(ctx) { @@ -38,7 +39,7 @@ function create_fragment(ctx) { }; } -const func = () => import('./Foo.svelte'); +const func = () => import("./Foo.svelte"); class Component extends SvelteComponent { constructor(options) { diff --git a/test/js/samples/event-modifiers/expected.js b/test/js/samples/event-modifiers/expected.js index 55ed17dace..f586a89be2 100644 --- a/test/js/samples/event-modifiers/expected.js +++ b/test/js/samples/event-modifiers/expected.js @@ -34,6 +34,7 @@ function create_fragment(ctx) { t3 = space(); button2 = element("button"); button2.textContent = "or me!"; + dispose = [ listen(button0, "click", stop_propagation(prevent_default(handleClick))), listen(button1, "click", handleClick, { once: true, capture: true }),