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

Allow disabling EventDispatcher assertion for tagless components / opt out of EventDispatcher #16816

Closed
buschtoens opened this issue Jul 12, 2018 · 3 comments

Comments

@buschtoens
Copy link
Contributor

This assertion is a major annoyance when trying to build container components:

Assertion Failed: You can not define a function that handles DOM events in the <twiddle@component:wrapper-component::ember276> tagless component since it doesn't have any DOM element.

ember-glimmer/lib/component.ts#L571

It is triggered, when you define methods or pass actions named like the default events or custom events that are handled by the EventDispatcher.

// components/wrapper-component/component.js
export default Ember.Component.extend({
  tagName: ''
});
{{!-- components/wrapper-component/template.hbs --}}
<button onclick={{action click}}>Click me</button>
{{wrapper-component click=(action "someAction")}}

Ember Twiddle Demo

While the assertion is technically correct, I explicitly want to opt out of it for some tagless components, in order to avoid having to use needlessly convoluted / verbose action names like onClick.

EventDispatcher calls handleEvent on ViewMixin, which delegates to the _currentState.handleEvent of the component, which is handleEvent of has_element (in_dom).

This function needs to check, whether the proposed opt-out flag is enabled and immediately return true then.

I'd love to submit a PR for this. Will this get accepted?

What should we call the flag? skipEventDispatcher or something like this?

@rwjblue
Copy link
Member

rwjblue commented Jul 12, 2018

I think that a better longer term solution would be to just avoid the issues completely via a custom component manager.

@buschtoens
Copy link
Contributor Author

buschtoens commented Jul 12, 2018

I assume you're talking about RFC #213?

Giving it another read now 😊

@buschtoens
Copy link
Contributor Author

buschtoens commented Jul 12, 2018

You are correct. I'll try to join efforts there.

#16301

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