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

refactor(Focus): Use handleEvent instead of arrow functions #291

Merged
merged 2 commits into from
Sep 23, 2017

Conversation

bigopon
Copy link
Member

@bigopon bigopon commented Jul 20, 2017

This PR replaces 2 arrow functions: focusListener & blurListener by handleEvent, leveraging event target interface for lower memory consumption.

@EisenbergEffect
Copy link
Contributor

Ok, this is awesome. I didn't even know about this API option. @jdanyow Can you think of any reason not to do this? @bigopon What if we also removed the extra methods and just inlined the behavior in the switch statement?

@bigopon
Copy link
Member Author

bigopon commented Aug 20, 2017

Inlined. But I don't why the whole content got blown away and replaced, despite being the same ... Is that an issue ?

@EisenbergEffect The API also motivated me to propose aurelia/binding#604, where in each Listener binding, we use the instance itself as listener instead of a newly created arrow function. That proposal contains 2 changes, in which 1 is breaking (Allow multiples events attached on the same element, 1 in template declaration, and 1 in element consumption). In my opinion, maybe just pull in the changes for API usage first, and leave the other for future discussion.

@EisenbergEffect
Copy link
Contributor

@bigopon It looks like it could be some sort of whitespace issue.

@jdanyow Can you review this and let me know if you see any issues. This looks like a good change and something we might be able to leverage in other places as well.

@bigopon
Copy link
Member Author

bigopon commented Sep 3, 2017

@EisenbergEffect @jdanyow I've also put in observer locator to address #273

@jdanyow
Copy link
Contributor

jdanyow commented Sep 17, 2017

The API is new- it's from aurelia/binding#620

Add ?w=1 to ignore whitespace differences on github. For example, here's this PR: https://github.com/aurelia/templating-resources/pull/291/files?w=1

Copy link
Contributor

@jdanyow jdanyow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (this.hasSubscribers = this.observerLocator.getObserver(this, 'value').hasSubscribers())

I don't think we can use this kind of logic to determine whether to add event listeners. Assumes binding order.

@bigopon
Copy link
Member Author

bigopon commented Sep 19, 2017

I've reverted all the changes. Couldn't think of binding order when attempted to fix that

@jdanyow jdanyow merged commit d0310d2 into aurelia:master Sep 23, 2017
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

Successfully merging this pull request may close these issues.

3 participants