Ole
Ole

Reputation: 47092

LitElement sets template reference to null if the reference is mutated?

This stackblitz mutates this.iframe:

  @query("#iframe")
  iframe: any;

  firstUpdated() {
    console.log("THE IFRAME IS: ", this.iframe);
    this.iframe.id = "";
    console.log("THE IFRAME IS: ", this.iframe);
  }

After the this.iframe.id statement executes this.iframe is null.

Any ideas why that's happening?

Upvotes: 2

Views: 211

Answers (1)

Ole
Ole

Reputation: 47092

It's my own bad. I'm querying the template by id and then changing the id to something else, which then repeats the query and sets the iframe to null since it cannot be found.

Upvotes: 1

Related Questions