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.

All content of a @Id mapped element are removed from the DOM

See original GitHub issue

Description of the bug / feature

If you have a template / component that modifies its child elements dynamically, you cannot use it with a LitTemplate as Flow will remove all the created children.

Minimal reproducible example

@JsModule("./views/empty/empty-view.ts")
@Tag("empty-view")
public class EmptyView extends LitTemplate {

    @Id
    private Div root;
}
import { customElement, html, LitElement, PropertyValues, query } from "lit-element";

@customElement("empty-view")
export class EmptyView extends LitElement {
  @query("#root")
  private root!: HTMLElement;

  createRenderRoot() {
    // Do not use a shadow root
    return this;
  }
  render() {
    return html`<div id="root"></div>`;
  }

  protected firstUpdated(_changedProperties: PropertyValues) {
    super.firstUpdated(_changedProperties);
    this.root.innerText = "Hello";
  }
}

Expected behavior

You see “Hello” in the view

Actual behavior

The view is empty. If you remove the @Id mapping, then you see “Hello”

Versions:

- Vaadin / Flow version: 18

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:22 (22 by maintainers)

github_iconTop GitHub Comments

1reaction
knoobiecommented, Feb 22, 2021

@mshabarov this looks kinda similar to the issue you are currently investigating https://github.com/vaadin/flow/issues/10086

0reactions
plekucommented, Apr 30, 2021

Sounds like this (serious) ticket #8975 that we already have.

It is now reopened and to be continued there

Read more comments on GitHub >

github_iconTop Results From Across the Web

removing an element in array within map in react
javascript - removing an element in array within map in react - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing ......
Read more >
Traversing the DOM with filter(), map(), and arrow functions
Traversing the DOM with filter(), map(), and arrow functions​​ Today I was trying to iterate through all the DOM elements with a certain...
Read more >
Lists and Keys - React
Keys help React identify which items have changed, are added, or are removed. Keys should be given to the elements inside the array...
Read more >
Map.prototype.delete() - JavaScript - MDN Web Docs - Mozilla
The delete() method removes the specified element from a Map object by key. ... Parameters. key. The key of the element to remove...
Read more >
Removing Items from an Array in JavaScript - Ultimate Courses
In this article, we'll explore a few different ways to remove an item from an array in JavaScript. I will also show you...
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