Skip to content

Is lit has diff mechanism when render ? #3245

Answered by bicknellr
happy-little-one asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, lit-html (the core rendering part of Lit) can be used in effectively the same way you would use a virtual DOM in that it isn't going to recreate that <span> every time you call render. However, Lit's html template tag doesn't return a tree of virtual nodes, but a TemplateResult, which render uses to decide if all the static pieces of that html call are already rendered into the destination container.

const f = (x) => html`<div>${x}</div>`;
render(f('This is the first render.'), document.body);
await new Promise(r => setTimeout(r, 3000));
render(f('This is the second render.'), document.body);

In the example above, lit-html will recognize that it was asked to render a TemplateResult t…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@happy-little-one
Comment options

@bicknellr
Comment options

@augustjk
Comment options

@bicknellr
Comment options

Answer selected by augustjk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants