fix: ensure muted DOM property works correctly in FF (#13751)

Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
pull/13834/head
Dominic Gannaway 11 months ago committed by GitHub
parent 185e112377
commit 17cb462ca4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: ensure muted DOM property works correctly in FF

@ -77,7 +77,9 @@ export function RegularElement(node, context) {
if (
node.attributes.some(
(attribute) => attribute.type === 'Attribute' && attribute.name === 'autofocus'
(attribute) =>
attribute.type === 'Attribute' &&
(attribute.name === 'autofocus' || attribute.name === 'muted')
)
) {
mark_subtree_dynamic(context.path);

@ -264,6 +264,7 @@ export function RegularElement(node, context) {
if (
!is_custom_element &&
attribute.name !== 'autofocus' &&
attribute.name !== 'muted' &&
(attribute.value === true || is_text_attribute(attribute))
) {
const name = get_attribute_name(node, attribute);
@ -531,6 +532,12 @@ function build_element_attribute_update_assignment(element, node_id, attribute,
return false;
}
// Special case for Firefox who needs it set as a property in order to work
if (name === 'muted') {
state.init.push(b.stmt(b.assignment('=', b.member(node_id, b.id('muted')), value)));
return false;
}
/** @type {Statement} */
let update;

@ -142,7 +142,7 @@ function is_static_element(node) {
return false;
}
if (attribute.name === 'autofocus') {
if (attribute.name === 'autofocus' || attribute.name === 'muted') {
return false;
}

@ -1,2 +1,2 @@
<div><video class="svelte-xyz" autoplay muted></video>
<video muted></video></div>
<div><video class="svelte-xyz" autoplay></video>
<video></video></div>

Loading…
Cancel
Save