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

add assertions for tagless component event handlers #12503

Merged
merged 1 commit into from
Oct 19, 2015
Merged

add assertions for tagless component event handlers #12503

merged 1 commit into from
Oct 19, 2015

Conversation

miguelcobain
Copy link
Contributor

Should application instance custom events be considered as well?

Should I access it using this.container.lookup('-application-instance:main')?

Feel free to tag this PR if needed.

/cc @rwjblue @mixonic

@rwjblue
Copy link
Member

rwjblue commented Oct 19, 2015

Yes, the custom events added by Ember.Application instances and Ember.ApplicationInstance instances should be included.

As discussed in #ember-dev in slack, I think the easiest/best way to do this would be via a small change to the EventDispatcher around here, changing that to something like:

    var events = this._handledEvents = assign({}, get(this, 'events'), addedEvents);

(or some better name than this._handledEvents)

this.tagName !== '' || !(() => {
var eventDispatcher = this.container.lookup('event_dispatcher:main');
var application = this.container.lookup('application:main');
var events = assign({}, eventDispatcher.events, application.customEvents);
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be removed with that tweak to the event dispatcher we discussed.

@rwjblue
Copy link
Member

rwjblue commented Oct 19, 2015

I left one more minor nit-pick, but this looks great to me.

@miguelcobain - Thank you for putting the time in and figuring this out!

`You can not define a function that handles DOM events in the \`${this}\` tagless component since it doesn't have any DOM element.`,
this.tagName !== '' || !(() => {
let eventDispatcher = this.container.lookup('event_dispatcher:main');
let events = (eventDispatcher && eventDispatcher._finalEvents) || {};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rwjblue Like this? :)

I think a test may be a bit paranoic here. Are we testing && and ||?

Copy link
Member

Choose a reason for hiding this comment

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

HA! Agreed. This looks good.

@miguelcobain
Copy link
Contributor Author

Should be ready now!
Failing tests don't seem related with this PR.

@rwjblue
Copy link
Member

rwjblue commented Oct 19, 2015

Restarted sauce labs tests.

rwjblue added a commit that referenced this pull request Oct 19, 2015
add assertions for tagless component event handlers
@rwjblue rwjblue merged commit 4f9a3bc into emberjs:master Oct 19, 2015
@rwjblue
Copy link
Member

rwjblue commented Oct 19, 2015

Thanks again @miguelcobain !

@miguelcobain
Copy link
Contributor Author

🎉

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.

2 participants