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

<pre use:myaction></pre> crashes #14971

Closed
ocavue opened this issue Jan 10, 2025 · 0 comments · Fixed by #14973
Closed

<pre use:myaction></pre> crashes #14971

ocavue opened this issue Jan 10, 2025 · 0 comments · Fixed by #14973

Comments

@ocavue
Copy link

ocavue commented Jan 10, 2025

Describe the bug

After updating svelte from v5.16.5 to v5.16.6 (or the latest v5.17.3), the following code doesn't work anymore:

<script lang="ts">
  import type { Action } from "svelte/action";

  const myaction: Action = (element) => {
    $effect(() => {
      let code = document.createElement("code");
      code.textContent = "Hello world";
      element.appendChild(code);
    });
  };
</script>

<div>
  <pre use:myaction></pre>
</div>

There is the error:

[vite-plugin-svelte] [plugin vite-plugin-svelte] Cannot read properties of undefined (reading 'type')
file: /private/tmp/test-sv2/svelte-pre-issue/src/routes/mypre.svelte
TypeError: [plugin vite-plugin-svelte] Cannot read properties of undefined (reading 'type')

It seems that #14922 causes this issue.

Reproduction

  1. Open https://stackblitz.com/github/issueset/svelte-pre-action-issue, and you will see the following error

    [plugin:vite-plugin-svelte] Cannot read properties of undefined (reading 'type')
    
  2. Downgrade the svelte version in package.json to 5.16.5, then everything works fine.

Logs

No response

System Info

System:
    OS: macOS 15.1.1
    CPU: (8) arm64 Apple M2
    Memory: 280.28 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.18.1 - /opt/homebrew/opt/node@20/bin/node
    npm: 10.8.2 - /opt/homebrew/opt/node@20/bin/npm
    pnpm: 9.15.3 - /opt/homebrew/opt/node@20/bin/pnpm
    bun: 1.1.26 - /opt/homebrew/bin/bun
  Browsers:
    Brave Browser: 122.1.63.169
    Chrome: 131.0.6778.265
    Chrome Canary: 134.0.6947.0
    Safari: 18.1.1
    Safari Technology Preview: 18.2
  npmPackages:
    svelte: 5.16.6 => 5.16.6

Severity

blocking an upgrade

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

Successfully merging a pull request may close this issue.

1 participant