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

Cannot use a Bracket Expression with :to bindings #496

phillipskevin opened this Issue Oct 16, 2018 · 1 comment


None yet
3 participants
Copy link

phillipskevin commented Oct 16, 2018

This works:

        <fr-om val:from="obj['from']"></fr-om>

...but this:

        <t-o val:to="obj['to']"></t-o>

Tries to set the literal "obj['to']" on the ViewModel instead of parsing the expression.

Here is a codepen:

This should use expression.parse:

"can.setValue": function setValue(newVal) {
scope.set(cleanVMName(scopeProp, scope), newVal);

like the other path does:

if (mustBeGettable || scopeProp.indexOf("(") >= 0 ) {
var parentExpression = expression.parse(scopeProp,{baseMethodType: "Call"});
return parentExpression.value(scope);
} else {


This comment has been minimized.

Copy link

justinbmeyer commented Nov 16, 2018

<t-o val:to="thing().bar"></t-o>
<t-o val:to="a[b].c[d].e"></t-o>
expression = {
  type: "lookup".
  key: "e",
  root: {
    type: "bracket",
    children: [{type: "lookup", key: "d"}],
    root: {.....}

Hard way

var expressionForObjectWeAreSetting = ast.root
objectSetting = canReflect.getValue( expression.value(scope) );
canReflect.setKeyValue(objectSetting, expression.key, VALUE );

Easy way

var observable = expression.value(scope);

return observable;

canReflect.setValue(observable, VALUE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment