Merge pull request #3530 from sveltejs/gh-3524

robustify bind:currentTime
pull/3538/head
Rich Harris 5 years ago committed by GitHub
commit 1a9f6b4a09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

@ -19,8 +19,10 @@ function create_fragment(ctx) {
function audio_timeupdate_handler() {
cancelAnimationFrame(audio_animationframe);
if (!audio.paused) audio_animationframe = raf(audio_timeupdate_handler);
audio_updating = true;
if (!audio.paused) {
audio_animationframe = raf(audio_timeupdate_handler);
audio_updating = true;
}
ctx.audio_timeupdate_handler.call(audio);
}

Loading…
Cancel
Save