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

Keyed each blocks break with component named Map #2612

Closed
s3ththompson opened this issue Apr 29, 2019 · 4 comments · Fixed by #2963
Closed

Keyed each blocks break with component named Map #2612

s3ththompson opened this issue Apr 29, 2019 · 4 comments · Fixed by #2963
Labels

Comments

@s3ththompson
Copy link

Keyed each blocks break with a component named Map, throwing the error 'target' is a required option. (Note, this happens whether Map is the component inside the block or the component with the each block in its template.)

It took a while to track this down... is Map a reserved component name? If so, is there any chance the error message could be improved?

https://svelte.dev/repl?version=3.1.0&gist=0f12697412a5adacf701e3f5b14f9a8a

@EmilTholin
Copy link
Member

EmilTholin commented Apr 29, 2019

Svelte uses a Map to keep track of elements in the keyed each block, and the global Map constructor is shadowed by the component and throws an error.

function create_fragment(ctx) {
  var button, t_1, each_blocks = [], each_1_lookup = new Map(), each_1_anchor, current, dispose;
  // ...
}

@Conduitry
Copy link
Member

block.add_variable(lookup, `new Map()`);

What would fix this in this case is using new window.Map here, but in general I'm not really sure how we want to handle deconflicting these sorts of things. There could be a bunch of common globals that generated code is currently assuming it's able to access.

@Conduitry Conduitry added the bug label Apr 29, 2019
@tomblachut
Copy link

@Conduitry Hmmm $ prefix is reserved already. What about aliasing used globals with it?

@Rich-Harris
Copy link
Member

can confirm this is fixed in 3.6.0

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.

5 participants