Skip to content

Commit 0ae56ff

Browse files
committed
fix: ensure muted DOM property works correctly in FF
1 parent ad578a5 commit 0ae56ff

File tree

6 files changed

+26
-3
lines changed

6 files changed

+26
-3
lines changed

.changeset/wise-timers-look.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: ensure muted DOM property works correctly in FF

packages/svelte/src/compiler/phases/2-analyze/visitors/RegularElement.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ export function RegularElement(node, context) {
7777

7878
if (
7979
node.attributes.some(
80-
(attribute) => attribute.type === 'Attribute' && attribute.name === 'autofocus'
80+
(attribute) =>
81+
attribute.type === 'Attribute' &&
82+
(attribute.name === 'autofocus' || attribute.name === 'muted')
8183
)
8284
) {
8385
mark_subtree_dynamic(context.path);

packages/svelte/src/compiler/phases/3-transform/client/visitors/RegularElement.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ export function RegularElement(node, context) {
242242
);
243243
}
244244
} else {
245+
debugger;
245246
/** If true, needs `__value` for inputs */
246247
const needs_special_value_handling =
247248
node.name === 'option' ||
@@ -263,6 +264,7 @@ export function RegularElement(node, context) {
263264
if (
264265
!is_custom_element &&
265266
attribute.name !== 'autofocus' &&
267+
attribute.name !== 'muted' &&
266268
(attribute.value === true || is_text_attribute(attribute))
267269
) {
268270
const name = get_attribute_name(node, attribute);
@@ -530,6 +532,11 @@ function build_element_attribute_update_assignment(element, node_id, attribute,
530532
return false;
531533
}
532534

535+
if (name === 'muted') {
536+
state.init.push(b.stmt(b.call('$.muted', node_id, value)));
537+
return false;
538+
}
539+
533540
/** @type {Statement} */
534541
let update;
535542

packages/svelte/src/compiler/phases/3-transform/client/visitors/shared/fragment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function is_static_element(node) {
142142
return false;
143143
}
144144

145-
if (attribute.name === 'autofocus') {
145+
if (attribute.name === 'autofocus' || attribute.name === 'muted') {
146146
return false;
147147
}
148148

packages/svelte/src/internal/client/dom/elements/misc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ export function autofocus(dom, value) {
2020
}
2121
}
2222

23+
/**
24+
* @param {HTMLVideoElement} dom
25+
* @param {boolean} value
26+
* @returns {void}
27+
*/
28+
export function muted(dom, value) {
29+
dom.muted = value;
30+
}
31+
2332
/**
2433
* The child of a textarea actually corresponds to the defaultValue property, so we need
2534
* to remove it upon hydration to avoid a bug when someone resets the form value.

packages/svelte/src/internal/client/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export {
3737
} from './dom/elements/attributes.js';
3838
export { set_class, set_svg_class, set_mathml_class, toggle_class } from './dom/elements/class.js';
3939
export { apply, event, delegate, replay_events } from './dom/elements/events.js';
40-
export { autofocus, remove_textarea_child } from './dom/elements/misc.js';
40+
export { autofocus, muted, remove_textarea_child } from './dom/elements/misc.js';
4141
export { set_style } from './dom/elements/style.js';
4242
export { animation, transition } from './dom/elements/transitions.js';
4343
export { bind_active_element } from './dom/elements/bindings/document.js';

0 commit comments

Comments
 (0)