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

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

Open
timephy opened this issue Jan 14, 2025 · 1 comment

Comments

@timephy
Copy link

timephy commented Jan 14, 2025

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

@timephy
Copy link
Author

timephy commented Jan 14, 2025

If this is intentional, it could make sense to produce a better error? It was not apparent to me that the snippet did not work because of the following.

<enhanced:img src="./image.jpg" /> // ✅
<enhanced:img src={"./image.jpg"} /> // ❌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant