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

Context inside {{#each}} broken #1

Open
arggh opened this issue Jan 27, 2020 · 1 comment
Open

Context inside {{#each}} broken #1

arggh opened this issue Jan 27, 2020 · 1 comment

Comments

@arggh
Copy link
Owner

arggh commented Jan 27, 2020

Transpilation with Decaffeinate seems to have broken the context handling in {{#each}} loops. The context for {{b}} in all the iterations seems to be the last item in the array. This wasn't caught with any of the tests, which all still run succesfully.

For example, with a viewmodel:

Template.test.viewmodel({
  items: ['foo', 'bar', 'biz'],
  log(item) {
    console.log(item);
  }
});

...and a template:

<template name="test">
  {{#each items}}
     <button {{b "click: log(this)"}}>Log {{this}}</button>
  {{/each}}
</template>

...clicking on all of the buttons (Log fooLog barLog biz) always logs biz.

Pinging @ManuelDeLeon with high hopes 🤞

@ManuelDeLeon
Copy link

Check out what happens on currentContext (viewmodel.coffee line 532):

  currentContext = ->
    if currentView
      Blaze.getData(currentView)
    else
      Template.instance()?.data

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

2 participants