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

Computed binding between two components throws error: flatten(...) is null #624

Closed
i80and opened this issue Jun 7, 2017 · 1 comment · Fixed by #627
Closed

Computed binding between two components throws error: flatten(...) is null #624

i80and opened this issue Jun 7, 2017 · 1 comment · Fixed by #627
Labels

Comments

@i80and
Copy link

i80and commented Jun 7, 2017

Description

I'm porting a feedback widget to Svelte. The widget has methods to add questions to a list; each question can either be a binary choice or a freeform text box. I want to funnel each question widget's value into an object mapping questionID -> answer in the parent component.

It looks like you can bind <input> element values to a computed attribute (e.g. https://svelte.technology/repl?version=1.22.2&gist=20fa77ffb878bdcc7a0e496df0df8e4f) but you cannot bind nested component state to a computed attribute.

Simple reproduction

https://svelte.technology/repl?version=1.22.2&gist=1aafb1485e848d0da03d647b40d75f28

Backtrace

TypeError: Cannot read property 'name' of null
    at Object.visitBinding [as Binding] (/Users/andrew/Documents/greni/node_modules/svelte/compiler/svelte.js:13339:40)
    at /Users/andrew/Documents/greni/node_modules/svelte/compiler/svelte.js:13439:35
    at Array.forEach (native)
    at visitComponent (/Users/andrew/Documents/greni/node_modules/svelte/compiler/svelte.js:13438:10)
    at visitElement (/Users/andrew/Documents/greni/node_modules/svelte/compiler/svelte.js:14264:16)
    at visit$1 (/Users/andrew/Documents/greni/node_modules/svelte/compiler/svelte.js:14605:5)
    at /Users/andrew/Documents/greni/node_modules/svelte/compiler/svelte.js:14404:9
    at Array.forEach (native)
    at visitChildren (/Users/andrew/Documents/greni/node_modules/svelte/compiler/svelte.js:14403:19)
    at getBranches (/Users/andrew/Documents/greni/node_modules/svelte/compiler/svelte.js:14384:5)
@i80and i80and changed the title Computed binding between two components throws error Computed binding between two components throws error: flatten(...) is null Jun 7, 2017
Rich-Harris added a commit that referenced this issue Jun 13, 2017
allow components to have computed member expressions for bindings
@Rich-Harris
Copy link
Member

Fixed in 1.22.3 — thanks

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.

2 participants