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 // 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) ${animation_frame} = @raf(${handler});`} if (!${this.var}.paused) {
${needs_lock && `${lock} = true;`} ${animation_frame} = @raf(${handler});
ctx.${handler}.call(${this.var}${contextual_dependencies.size > 0 ? ', ctx' : ''}); ${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; callee = handler;
} else { } else {

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

Loading…
Cancel
Save