Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nullish srcset attribute crashes Svelte (4.0.2) #8899

Closed
vschoettke opened this issue Jul 3, 2023 · 0 comments · Fixed by #8901
Closed

nullish srcset attribute crashes Svelte (4.0.2) #8899

vschoettke opened this issue Jul 3, 2023 · 0 comments · Fixed by #8901
Labels

Comments

@vschoettke
Copy link

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

@Conduitry Conduitry added the bug label Jul 3, 2023
dummdidumm added a commit that referenced this issue Jul 3, 2023
dummdidumm added a commit that referenced this issue Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants