pull/3530/head
Richard Harris 5 years ago
parent 63ae77112c
commit 4ad36406bc

@ -468,17 +468,25 @@ export default class ElementWrapper extends Wrapper {
// TODO dry this out — similar code for event handlers and component bindings // TODO dry this out — similar code for event handlers and component bindings
if (has_local_function) { if (has_local_function) {
// need to create a block-local function that calls an instance-level function // need to create a block-local function that calls an instance-level function
block.builders.init.add_block(deindent` if (animation_frame) {
function ${handler}() { block.builders.init.add_block(deindent`
${animation_frame && deindent` function ${handler}() {
@_cancelAnimationFrame(${animation_frame}); @_cancelAnimationFrame(${animation_frame});
if (!${this.var}.paused) { if (!${this.var}.paused) {
${animation_frame} = @raf(${handler});`} ${animation_frame} = @raf(${handler});
${needs_lock && `${lock} = true;`}
}
ctx.${handler}.call(${this.var}${contextual_dependencies.size > 0 ? ', ctx' : ''});
}
`);
} else {
block.builders.init.add_block(deindent`
function ${handler}() {
${needs_lock && `${lock} = true;`} ${needs_lock && `${lock} = true;`}
ctx.${handler}.call(${this.var}${contextual_dependencies.size > 0 ? ', ctx' : ''});
} }
ctx.${handler}.call(${this.var}${contextual_dependencies.size > 0 ? ', ctx' : ''}); `);
} }
`);
callee = handler; callee = handler;
} else { } else {

Loading…
Cancel
Save