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

Bug when binding to objects using string keys (test case included) #241

Closed
AlexanderDzhoganov opened this issue Nov 23, 2015 · 1 comment
Labels

Comments

@AlexanderDzhoganov
Copy link

We have discovered an issue when binding to nested objects using string keys. We run a relatively large app on Aurelia and this took us a while to discover and reproduce but we have nailed it down to a simple test case using the ES 2016 Kit from the Getting Started guide.

The code that triggers the bug is this:

app.js

export class App {
  foo = {
    bar: {
      baz: 3.1415
    }
  };

  indexVar = 'bar';
}

app.html

<template>
  <div if.bind="indexVar">
    ${foo[indexVar]['baz']}
  </div>

  <button type="button" click.delegate="indexVar = undefined">Unset</button>
</template>

If you click the button the following error is printed to Chrome's console:

Uncaught TypeError: Cannot read property 'baz' of undefined @ aurelia-task-queue.js:40

By changing the line

${foo[indexVar]['baz']}

to

${foo[indexVar].baz}

the issue disappears and the code works as expected.

@jdanyow
Copy link
Contributor

jdanyow commented Nov 23, 2015

Thanks for the clear steps to reproduce! Will get this fixed asap.

http://plnkr.co/edit/KD7GTO?p=preview

@jdanyow jdanyow added the bug label Nov 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants