Ember.js: [Beta regression] `this.elementId` is null in tagless component

Created on 9 Jun 2016  路  7Comments  路  Source: emberjs/ember.js

In 2.6, this.elementId called from within a tagless component returned something like ember123.
In 2.7 the same call in 2.7.0-beta.0 returns null.

Intended or a regression?

Needs Team Response

Most helpful comment

Add me to list as missing this ability. Building in accessibility relationships in tagless components was much easier with it!

All 7 comments

Well, it seems unintentional, but the new behavior does seem logical. Why would something without an element have an elementId? Why do extra work to calculate an elementId when it isn't going to be used?

Is this a large issue for your addons?

Not a big deal, it is an easy fix.
I just needed a unique identifier from which derive ids for the trigger and the content so I can relate them (since the content may be rendered in the root of the page, A11y requires some hint).
I could just as easy generate an autoincremental number myself, but since I had this.elementId I was using it, assuming that it was an identifier for the component, regardless of if the component had a DOM element or not.

I will stop relying on it, but I wanted to raise this change.

Thank you for reporting.

I will check with others to see if we should bring it back or try and do a deprecation. I'm unsure how big of an issue it is for others though...

Thank you again for reporting the issue. If we have significant reports of this in future releases we can revisit, but for now I'm going to close...

Add me to list as missing this ability. Building in accessibility relationships in tagless components was much easier with it!

was this fixed?

Just for the record (for future reference), we can use Ember.guidFor(this) to generate the id and use it in the template.

Was this page helpful?
0 / 5 - 0 ratings