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

multiple method calls with different argument sequence #466

Closed
hville opened this issue Apr 11, 2017 · 2 comments · Fixed by #467
Closed

multiple method calls with different argument sequence #466

hville opened this issue Apr 11, 2017 · 2 comments · Fixed by #467
Labels

Comments

@hville
Copy link
Contributor

hville commented Apr 11, 2017

Iterating through a matrix with nested loops (i, j), the same method gets called twice with the arguments swapped depending on their relative values REPL. Extract below.

{{#each triangularMatrix as ri, i}}
<tr>
  {{#each triangularMatrix as rj, j}}
    {{#if i > j}}
      <td><input type="number" value={{ri[j]}} on:click='lowerThan(j, i)'></td>
    {{elseif i === j}}
      <td>1</td>
    {{else}}
      <td><input type="number" value={{rj[i]}} on:click='lowerThan(i, j)'></td>
    {{/if}}
  {{/each}}
</tr>
{{/each}}

the lowerThan function is called twice with the arguments swapped:

  • if i < j, <td ... on:click='lowerThan(i, j) //correct
  • if i > j, <td ... on:click='lowerThan(j, i) //always fails

In the generated code, a single change handler is registered and the arguments get swapped on the second call (ie the second assertion always fails).

The indices in the view are fine, the problem is only with the event handlers

@hville hville changed the title multiple method calls with different argument sequence get 're-sorted' multiple method calls with different argument sequence Apr 11, 2017
@Rich-Harris
Copy link
Member

I think I know what's going on here — two event handlers are being created, but they're both being given the name click_handler rather than click_handler and click_handler_1. Fairly sure I know how to fix that... on it

@Rich-Harris
Copy link
Member

This is fixed in 1.14 — 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