All content of a @Id mapped element are removed from the DOM
See original GitHub issueDescription 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:
- Created 3 years ago
- Comments:22 (22 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mshabarov this looks kinda similar to the issue you are currently investigating https://github.com/vaadin/flow/issues/10086
It is now reopened and to be continued there