diff --git a/src/compile/render-dom/wrappers/Window.ts b/src/compile/render-dom/wrappers/Window.ts index 7bf41cdc0b..c986d3726f 100644 --- a/src/compile/render-dom/wrappers/Window.ts +++ b/src/compile/render-dom/wrappers/Window.ts @@ -146,9 +146,9 @@ export default class WindowWrapper extends Wrapper { ${scrolling} = true; clearTimeout(${scrolling_timeout}); window.scrollTo(${ - bindings.scrollX ? `current["${bindings.scrollX}"]` : `window.pageXOffset` + bindings.scrollX ? `ctx.${bindings.scrollX}` : `window.pageXOffset` }, ${ - bindings.scrollY ? `current["${bindings.scrollY}"]` : `window.pageYOffset` + bindings.scrollY ? `ctx.${bindings.scrollY}` : `window.pageYOffset` }); ${scrolling_timeout} = setTimeout(${clear_scrolling}, 100); } diff --git a/test/js/samples/window-binding-scroll/expected.js b/test/js/samples/window-binding-scroll/expected.js index a613882827..7a5e291866 100644 --- a/test/js/samples/window-binding-scroll/expected.js +++ b/test/js/samples/window-binding-scroll/expected.js @@ -29,7 +29,7 @@ function create_fragment($$, ctx) { if (changed.y && !scrolling) { scrolling = true; clearTimeout(scrolling_timeout); - window.scrollTo(window.pageXOffset, current["y"]); + window.scrollTo(window.pageXOffset, ctx.y); scrolling_timeout = setTimeout(clear_scrolling, 100); }