Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX an issue when re-rendering lit-html elements after rendering a non-lit-html element #5868

Merged
merged 4 commits into from
Mar 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions app/polymer/src/client/preview/render.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { document } from 'global';
import { stripIndents } from 'common-tags';
import { html, render, TemplateResult } from 'lit-html';
import { render, TemplateResult } from 'lit-html';

const rootElement = document.getElementById('root');

Expand Down Expand Up @@ -32,10 +32,12 @@ export default function renderMain({
// `render` stores the TemplateInstance in the Node and tries to update based on that.
// Since we reuse `rootElement` for all stories, remove the stored instance first.
// But forceRender means that it's the same story, so we want too keep the state in that case.
if (!forceRender) {
render(html``, rootElement);
if (!forceRender || !rootElement.querySelector('[id="root-inner"]')) {
rootElement.innerHTML = '<div id="root-inner"></div>';
}
render(element, rootElement);
const renderTo = rootElement.querySelector('[id="root-inner"]');

render(element, renderTo);
} else {
rootElement.innerHTML = '';
rootElement.appendChild(element);
Expand Down