Skip to content

Commit

Permalink
Add mount condition for playbackRate and volume
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasBuelens committed Nov 12, 2019
1 parent 92710f8 commit ed4f89d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export default class BindingWrapper {
case 'playbackRate':
case 'volume':
update_conditions.push(x`!@_isNaN(${this.snippet})`);
mount_conditions.push(x`!@_isNaN(${this.snippet})`);
break;

case 'paused':
Expand Down
10 changes: 8 additions & 2 deletions test/js/samples/media-bindings/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ function create_fragment(ctx) {
},
m(target, anchor) {
insert(target, audio, anchor);
audio.volume = ctx.volume;
audio.playbackRate = ctx.playbackRate;

if (!isNaN(ctx.volume)) {
audio.volume = ctx.volume;
}

if (!isNaN(ctx.playbackRate)) {
audio.playbackRate = ctx.playbackRate;
}
},
p(changed, ctx) {
if (!audio_updating && changed.currentTime && !isNaN(ctx.currentTime)) {
Expand Down

0 comments on commit ed4f89d

Please sign in to comment.