I'm hoping to get the host template attributes, but this.template.host is null.

e.g. something like:

connectedCallback() {

In the rendered markup in the browser, my LWC looks like:

<c-my-lwc aria-describedby='a-value'>
    [additional html content]

I'm hoping the console.log could output 'a-value'.

NOTE: this is a bit of an XY problem, but I don't see any other way of solving my problem.

I was looking at this question: Can an LWC component get its own name?

In this question, the answer refers to getting this.template.host.localName, but given this.template.host is null, I'm not sure how to do this.

1 Answer 1


Turns out it was simpler than I thought.

You just need to use this.getAttribute('aria-describedby').


connectedCallback() {

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .