Skip to content

fix: handle a state, a prop or an {#each} item named __proto__ - #19302

Open
fgallaire wants to merge 1 commit into
sveltejs:mainfrom
fgallaire:proto-named-binding
Open

fgallaire wants to merge 1 commit into
sveltejs:mainfrom
fgallaire:proto-named-binding

Conversation

@fgallaire

Copy link
Copy Markdown
<!-- Child.svelte -->
<script>
        let { __proto__ = 3 } = $props();
</script>

<p>{__proto__}</p>
<!-- App.svelte -->
<script>
        import Child from './Child.svelte';
          
        let __proto__ = $state(1);
        let rows = $state([5, 6]);
</script>

<button onclick={() => (__proto__ += 1)}>{__proto__}</button>
<Child />
<Child __proto__={10} />
 
{#each rows as __proto__}
        <span>{__proto__}</span>
{/each} 

Client-rendered:

- <button>[object Object]</button>
- <p>() => { var value = /** @type {V} */ (props[key]); if (value === undefined) return get_fallback(); fallback_dirty = true; return value; }</p>
- <p>() => { var value = /** @type {V} */ (props[key]); if (value === undefined) return get_fallback(); fallback_dirty = true; return value; }</p>
- <span>[object Object]</span><span>[object Object]</span>
+ <button>1</button>
+ <p>3</p>
+ <p>10</p>
+ <span>5</span><span>6</span>

@pkg-svelte-dev

Copy link
Copy Markdown

Install the latest version of svelte from 33b88fa:

pnpm add https://pkg.svelte.dev/svelte/c/33b88fa8e03f7b02ad1363b7c1a7efb4f077211e

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/svelte/pr/19302

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 33b88fa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

b.declarator(
/** @type {Pattern} */ (context.visit(id)),
proto
? b.call('Object.assign', b.call('Object.create', b.null), b.id('$$props'))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A component declaring both a __proto__ prop and a local Object binding crashes during SSR because the generated initializer references the shadowed Object.

Fix on Vercel

This branch has not been deployed

No deployments
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 this pull request may close these issues.

1 participant