sveltejs / sveltejs/kit

`enhanced-img` `snippet test(src: string)` results in "TypeError: Cannot read properties of undefined (reading 'src')"

Open
#13,313 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pkg:enhanced-img
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the bug
// This works ✅
<enhanced:img src="./image.jpg" />

// This does NOT ❌
{#snippet imgSnip(src: string)}
    <enhanced:img {src} />
{/snippet}
{@render imgSnip("./image.jpg")}

// Neither does this...
<enhanced:img src={"./image.jpg"} />
Reproduction

Please see above.

Logs

The error during pnpm run dev reads:

TypeError: Cannot read properties of undefined (reading 'src')
System Info
System:
    OS: macOS 15.2
    CPU: (20) x64 Intel(R) Xeon(R) W-2150B CPU @ 3.00GHz
    Memory: 123.22 MB / 64.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 23.5.0 - /usr/local/bin/node
    Yarn: 1.22.11 - /usr/local/bin/yarn
    npm: 10.9.2 - /usr/local/bin/npm
    pnpm: 9.15.2 - /usr/local/bin/pnpm
    bun: 1.1.34 - ~/code/grouptube/frontend/node_modules/.bin/bun
  Browsers:
    Chrome: 131.0.6778.265
    Safari: 18.2
  npmPackages:
    @sveltejs/adapter-node: ^5.2.11 => 5.2.11 
    @sveltejs/adapter-static: ^3.0.8 => 3.0.8 
    @sveltejs/enhanced-img: ^0.4.4 => 0.4.4 
    @sveltejs/kit: ^2.15.0 => 2.15.0 
    @sveltejs/vite-plugin-svelte: 5.0.3 => 5.0.3 
    svelte: 5.15.0 => 5.15.0 
    vite: ^6.0.1 => 6.0.1
Severity

serious, but I can work around it

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The report provides no repository file or test path; start by reproducing the examples with @sveltejs/enhanced-img 0.4.4, Svelte 5.15.0, and Vite 6.0.1 using pnpm run dev. Done means both the snippet-bound src and the expression-bound src render without the undefined-src TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, vite
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.