diff --git a/src/compile/render-dom/wrappers/Element/index.ts b/src/compile/render-dom/wrappers/Element/index.ts index 7bca57fa0a..b61a88cb62 100644 --- a/src/compile/render-dom/wrappers/Element/index.ts +++ b/src/compile/render-dom/wrappers/Element/index.ts @@ -494,7 +494,7 @@ export default class ElementWrapper extends Wrapper { block.addVariable(resize_listener); block.builders.mount.addLine( - `${resize_listener} = @addResizeListener(${this.var}, ${callee});` + `${resize_listener} = @addResizeListener(${this.var}, ${callee}.bind(${this.var}));` ); block.builders.destroy.addLine( diff --git a/test/js/samples/bind-width-height/expected.js b/test/js/samples/bind-width-height/expected.js index f97a6d81e5..d1396fe895 100644 --- a/test/js/samples/bind-width-height/expected.js +++ b/test/js/samples/bind-width-height/expected.js @@ -13,7 +13,7 @@ function create_fragment(component, ctx) { m(target, anchor) { insert(target, div, anchor); - div_resize_listener = addResizeListener(div, ctx.div_resize_handler); + div_resize_listener = addResizeListener(div, ctx.div_resize_handler.bind(div)); current = true; },