From 811c8d32ebcd38501ec5acf1eabe461693bc24d7 Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Wed, 20 Nov 2024 15:19:17 +0000 Subject: [PATCH] fix: correctly handle srcObject attribute on video elements (#14369) * fix: correctly handle srcObject attribute on video elements * remove side-effect * side-effects agin * side-effects agin * better fix --- .changeset/bright-jokes-bow.md | 5 +++++ packages/svelte/src/utils.js | 6 ++++-- .../samples/video-src-object/_config.js | 12 ++++++++++++ .../samples/video-src-object/main.svelte | 10 ++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 .changeset/bright-jokes-bow.md create mode 100644 packages/svelte/tests/runtime-runes/samples/video-src-object/_config.js create mode 100644 packages/svelte/tests/runtime-runes/samples/video-src-object/main.svelte diff --git a/.changeset/bright-jokes-bow.md b/.changeset/bright-jokes-bow.md new file mode 100644 index 0000000000..f70076b869 --- /dev/null +++ b/.changeset/bright-jokes-bow.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: correctly handle srcObject attribute on video elements diff --git a/packages/svelte/src/utils.js b/packages/svelte/src/utils.js index 84c7ca1efb..919660fd6a 100644 --- a/packages/svelte/src/utils.js +++ b/packages/svelte/src/utils.js @@ -192,7 +192,8 @@ const ATTRIBUTE_ALIASES = { ismap: 'isMap', nomodule: 'noModule', playsinline: 'playsInline', - readonly: 'readOnly' + readonly: 'readOnly', + srcobject: 'srcObject' }; /** @@ -212,7 +213,8 @@ const DOM_PROPERTIES = [ 'readOnly', 'value', 'inert', - 'volume' + 'volume', + 'srcObject' ]; /** diff --git a/packages/svelte/tests/runtime-runes/samples/video-src-object/_config.js b/packages/svelte/tests/runtime-runes/samples/video-src-object/_config.js new file mode 100644 index 0000000000..a31b98cac6 --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/video-src-object/_config.js @@ -0,0 +1,12 @@ +import { test } from '../../test'; + +export default test({ + html: ``, + + test({ assert, target }) { + const video = target.querySelector('video'); + + // @ts-ignore + assert.deepEqual(video?.srcObject, {}); + } +}); diff --git a/packages/svelte/tests/runtime-runes/samples/video-src-object/main.svelte b/packages/svelte/tests/runtime-runes/samples/video-src-object/main.svelte new file mode 100644 index 0000000000..f4059b028a --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/video-src-object/main.svelte @@ -0,0 +1,10 @@ + + + +