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.

Tagless component defined with ES Class causes error

See original GitHub issue

I am trying to use ES class syntax (this is because I am actually using ember-typescript, but this issue is not related to that project). As I understand the RFC for this was merged some time last year and some work has been done in this space to support projects like ember-cli-typescript and ember-decorators. I have read the RFC and am using the class syntax correctly from what I understand but perhaps I am still doing something wrong. I am trying to have a tagless element through tagName = '' but the way ES classes are implemented seems to have a problem with this.

See the following example, which I’ve created in this ember twiddle:

import Ember from 'ember';

export default class MyComponent extends Ember.Component {
  constructor() {
    super();
    
    // Empty string causes runtime error
    // "Assertion Failed: You cannot use `elementId` on a tag-less component"
    // Comment this line to fix
    this.tagName = '';
    this.debug = "Lorem ipsum dolor sit amet";
  }
}

This compiles fine, but when I visit the page I get a strange Error:

Assertion Failed: You cannot use `elementId` on a tag-less component: <component name>

I am unsure if I’m doing things wrong, if i’ve uncovered a legitimate bug, or if this is just something that is not yet implemented. Any ideas?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
rwjbluecommented, Apr 9, 2019

Sorry for the run around here, @pzuraq’s last reply is spot on.

I’m going to go ahead and close this as a (very polite and apologetic) “wont fix”.

1reaction
pzuraqcommented, Mar 27, 2019

We do not support using classic components with native classes directly in Ember. In order to customize the element, you should use ember-decorators, specifically the @tagName class decorator.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Go - How can I subtype a wrapped error class? - Stack Overflow
Errorf to produce a new error value that wraps the lower-level error. You can then use errors.Is within a tagless switch to inspect...
Read more >
Deprecations Added in Ember 3.x
We are deprecating usage of new EmberObject() to construct instances of EmberObject and it's subclasses. This affects all classes that extend from EmberObject ......
Read more >
ember-classic-decorator - npm
Decorator to aide migration from classic class system to native classes. ... cause a lint error if used in a non-classic class definition....
Read more >
Overview - Izumi Project
distage creates components at most once, even if multiple other objects depend on ... for other bindings are merely unset, it will cause...
Read more >
Functional Testing with Tagless-Final | by Amitay Horwitz
It allows us to explicitly describe which effects are needed by each part of the program, giving us the ability to reason about...
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