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

TypeError: Cannot read property 'dependencies' of undefined #961

Closed
EmilTholin opened this issue Nov 26, 2017 · 2 comments · Fixed by #965
Closed

TypeError: Cannot read property 'dependencies' of undefined #961

EmilTholin opened this issue Nov 26, 2017 · 2 comments · Fixed by #965

Comments

@EmilTholin
Copy link
Member

[email protected] throws TypeError: Cannot read property 'dependencies' of undefined when certain attributes don't have explicit values. I'm not 100% sure what causes it, but this basic repro illustrates the issue.

This works great:

<Component exact={{true}} href="/cool"/>

This throws the error:

<Component exact href="/cool"/>
Stack trace TypeError: Cannot read property 'dependencies' of undefined at error (/Users/emil/Code/svelte-dependencies-undefined/node_modules/rollup/dist/rollup.js:189:14) at Object.error (/Users/emil/Code/svelte-dependencies-undefined/node_modules/rollup/dist/rollup.js:17549:6) at promise.then.previous (/Users/emil/Code/svelte-dependencies-undefined/node_modules/rollup/dist/rollup.js:17558:32) at at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:678:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
@Rich-Harris
Copy link
Member

Thanks — this is a fun bug. When Svelte walks the template, it does so with estree-walker, which builds up a map of child keys for each node type (e.g. an Element node has attributes and children properties). If the first example of a given node type has a misleading 'shape', it will get all the subsequent nodes of that type wrong unless you configure it — in this case, it was encountering an Attribute node with a value property that was true (i.e. not an object, and therefore not a 'child' property), and thus skipping value on all subsequent Attribute nodes. Fixed in #965!

Rich-Harris added a commit that referenced this issue Nov 27, 2017
prevent boolean attributes breaking shapes inside estree-walker
@EmilTholin
Copy link
Member Author

Awesome! Thanks Rich!

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.

2 participants