-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Labels
Description
Describe the bug
Passing a srcset={null}
or srcset={undefined}
to an image results in a crash. In my case the srcset
is generated with a function that returns undefined when the image is an SVG.
The problem only occurred after upgrading from Svelte 4.0.1 to 4.0.2.
Probably introduced with #8838, but I wonder why the srcset_url_equal
function is called anyway when the srcset
is nullish.
Reproduction
I a repl for reproducing the error here:
https://svelte.dev/repl/4e3cac66da884b7dbe88d988fc9edcc7?version=4.0.2
You can see
"Cannot read properties of null (reading 'split')" in the bottom right.
Logs
TypeError: Cannot read properties of undefined (reading 'split') at split_srcset
(http://localhost:5173/node_modules/.vite/deps/chunk-WHDRF6EJ.js?v=1735e15a:55:17) at srcset_url_equal
(http://localhost:5173/node_modules/.vite/deps/chunk-WHDRF6EJ.js?v=1735e15a:59:16) at Object.hydrate [as h]
System Info
System:
OS: macOS 12.6.7
CPU: (10) arm64 Apple M1 Pro
Memory: 137.28 MB / 16.00 GB
Shell: 3.2.57 - /bin/sh
Binaries:
Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v18.16.0/bin/yarn
npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
Browsers:
Chrome: 114.0.5735.198
Safari: 16.5.1
npmPackages:
svelte: ^4.0.2 => 4.0.2
Severity
blocking an upgrade