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

Rich type coercion breaks with bi-directional bindings (version 3.11.12) #486

Open
imaustink opened this issue Sep 11, 2018 · 0 comments
Open

Comments

@imaustink
Copy link
Contributor

The following example should render Austin twice, once in and again in the call to stache near the bottom. However, only the first instance is rendered. Note if you change the value passed into the template to be an instance of User rather than a POJO, it works as expected.

const User = can.DefineMap.extend({
  name: {
    type: 'string',
    value: 'Austin'
  }
})

can.Component.extend({
  tag: 'my-component',
  view: can.stache(`<p>{{user.name}}</p>`),
  ViewModel: can.DefineMap.extend({
    user: {
      Type: User
    }
  })
})

const template = can.stache(`
  <my-component user:bind="user"></my-component>
  <p>{{user.name}}</p>
`)
const frag = template(new can.DefineMap({
  user: {} // change this to `new User()` and it works
}))

document.body.appendChild(frag)

Working codepen for convenience:
https://codepen.io/anon/pen/eLMvBZ?editors=1111

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

No branches or pull requests

1 participant