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

7guis example broken #486

Closed
Rich-Harris opened this issue Apr 15, 2017 · 2 comments
Closed

7guis example broken #486

Rich-Harris opened this issue Apr 15, 2017 · 2 comments
Labels

Comments

@Rich-Harris
Copy link
Member

Still trying to figure out exactly why, but adjusting the diameter in the 7guis circles example (click to create a circle, right-click to bring up the adjuster dialog) is broken:

@Conduitry
Copy link
Member

Conduitry commented Apr 16, 2017

It looks like this has to do with a single input element with both a bind: directive and an on: directive for the same event that calls component.set. A simple reproduction:

<input bind:value='a' on:input='set({ b: 0 })'>

When an input event comes in, the on:input handler is called first. This eventually calls _fragment.update with the whole new state, which includes the old value for a. The input element is set back to its old value, and then when we get into the other event handler for the bind:value, when we look at .value it has the old value in it again.

Having the event handler for the bind: attached first so that it is run before the event handler for the on: is run seems to address this specific issue, but I don't know whether that is in general a solution or something we want to do.

Edit: Is there a particular reason for the ordering given here? From a brief test, swapping the Binding and EventHandler in the ordering looks like it takes care of this.

@Rich-Harris
Copy link
Member Author

Thank you! I was scratching my head over this one. There's no particular reason for that ordering, I just wanted there to be some order (i.e. all attributes grouped together) for the sake of readability. Now that we've encountered a situation where the order actually does matter, we can control it. I can't think of a situation where bindings would need to update after regular event listeners have fired, so I'm happy with that solution — we can revisit that in future if it proves necessary.

Rich-Harris added a commit that referenced this issue Apr 16, 2017
ensure binding event handlers precede normal ones
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