question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Working with Custom Elements and Events

See original GitHub issue

I’m having a bit of trouble working with custom elements in an Ember app, and I think it comes from some assumptions that Glimmer makes about angle-bracket components.

If I have some custom element (say os-modal for example) that I want to bind a custom event listener do, I want to do something like this:

<os-modal {{action 'onModalClose' on='modalclose'}}>
  Some modal content
</os-modal>

However, I get an error from Glimmer:

Element modifiers are not allowed in components

The problem is that Glimmer has no way (that I know of) to tell the compiler that os-modal is not a Glimmer component, and to treat it like any other HTML element.

Is there actually a way to tell Glimmer (or Ember) about non-Glimmer custom elements? If not, what would the steps be to work on that, and RFC for Glimmer? For Ember?

Original issue: https://github.com/ember-cli/ember-cli/issues/6925

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
wycatscommented, Apr 29, 2018

The latest version of the Glimmer VM uses capital letters rather than dasherized names as the signal that it’s looking at a component.

This should fix this issue, I think.

1reaction
jasonmitcommented, Apr 27, 2018
<os-modal {{action 'onModalClose' on='modalclose'}}>
  Some modal content
</os-modal>

The newer versions of glimmer seem to no longer has this issue. Within Ember, it was fixed in 3.1.0 most likely because of https://github.com/emberjs/ember.js/pull/15828

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using custom elements - Web Components | MDN
The controller of custom elements on a web document is the CustomElementRegistry object — this object allows you to register a custom element...
Read more >
Knowledge: Events - Open Web Components
Thankfully, the custom elements specification outlines the connectedCallback and disconnectedCallback lifecycle methods. These are the perfect hooks for ...
Read more >
Working with Custom Events and Web Components
First, your custom event has to use the composed property. I found this on StackOverflow and you can read more about it on...
Read more >
Custom Elements, event listener and this - Jonas Fährmann
My name is Jonas Fährmann. I am a Frontend Developer/Designer from Münster, NRW, Germany. This is my online Portfolio.
Read more >
Web Components API: Lifecycle Events and Custom Events
Creating and triggering custom events. Native events are the main way we have to add interactivity on the web as we execute some...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found