Skip to content

Commit ed4f89d

Browse files
Add mount condition for playbackRate and volume
1 parent 92710f8 commit ed4f89d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/compiler/compile/render_dom/wrappers/Element/Binding.ts

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ export default class BindingWrapper {
140140
case 'playbackRate':
141141
case 'volume':
142142
update_conditions.push(x`!@_isNaN(${this.snippet})`);
143+
mount_conditions.push(x`!@_isNaN(${this.snippet})`);
143144
break;
144145

145146
case 'paused':

test/js/samples/media-bindings/expected.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,14 @@ function create_fragment(ctx) {
5858
},
5959
m(target, anchor) {
6060
insert(target, audio, anchor);
61-
audio.volume = ctx.volume;
62-
audio.playbackRate = ctx.playbackRate;
61+
62+
if (!isNaN(ctx.volume)) {
63+
audio.volume = ctx.volume;
64+
}
65+
66+
if (!isNaN(ctx.playbackRate)) {
67+
audio.playbackRate = ctx.playbackRate;
68+
}
6369
},
6470
p(changed, ctx) {
6571
if (!audio_updating && changed.currentTime && !isNaN(ctx.currentTime)) {

0 commit comments

Comments
 (0)