diff --git a/src/compiler/compile/render_dom/wrappers/Window.ts b/src/compiler/compile/render_dom/wrappers/Window.ts index e36f55722a..b9a32c03fd 100644 --- a/src/compiler/compile/render_dom/wrappers/Window.ts +++ b/src/compiler/compile/render_dom/wrappers/Window.ts @@ -127,11 +127,7 @@ export default class WindowWrapper extends Wrapper { component.partly_hoisted.push(b` function ${id}() { - ${props.map(prop => - prop.name[0] === '$' - ? b`${prop.name.slice(1)}.set(${prop.name} = @_window.${prop.value});` - : b`$$invalidate('${prop.name}', ${prop.name} = @_window.${prop.value});` - )} + ${props.map(prop => component.invalidate(prop.name, x`${prop.name} = @_window.${prop.value}`))} } `); @@ -169,11 +165,9 @@ export default class WindowWrapper extends Wrapper { referenced: true }); - const invalidate = name[0] === '$' ? b`${name.slice(1)}.set(${name} = @_navigator.onLine)` : b`$$invalidate('${name}', ${name} = @_navigator.onLine);`; - component.partly_hoisted.push(b` function ${id}() { - ${invalidate} + ${component.invalidate(name, x`${name} = @_navigator.onLine`)} } `); diff --git a/test/js/samples/window-binding-scroll-store/expected.js b/test/js/samples/window-binding-scroll-store/expected.js index 6237991da0..92fb470f20 100644 --- a/test/js/samples/window-binding-scroll-store/expected.js +++ b/test/js/samples/window-binding-scroll-store/expected.js @@ -111,7 +111,7 @@ function instance($$self, $$props, $$invalidate) { component_subscribe($$self, y_squared, value => $$invalidate("$y_squared", $y_squared = value)); function onwindowscroll() { - y.set($y = window.pageYOffset); + y.set($y = window.pageYOffset) } return { diff --git a/test/js/samples/window-binding-scroll/expected.js b/test/js/samples/window-binding-scroll/expected.js index 87f31505d7..4cd784e2bf 100644 --- a/test/js/samples/window-binding-scroll/expected.js +++ b/test/js/samples/window-binding-scroll/expected.js @@ -68,7 +68,7 @@ function instance($$self, $$props, $$invalidate) { let { y } = $$props; function onwindowscroll() { - $$invalidate("y", y = window.pageYOffset); + $$invalidate("y", y = window.pageYOffset) } $$self.$set = $$props => {