Don't use document fragment

This commit is contained in:
toasted-nutbread 2019-12-27 18:15:16 -05:00
parent 7a6f85879e
commit 97f7df3302
2 changed files with 23 additions and 22 deletions

View File

@ -42,6 +42,7 @@ body {
margin: 0; margin: 0;
border: 0; border: 0;
padding: 0; padding: 0;
overflow-y: scroll; /* always show scroll bar */
} }
ol, ul { ol, ul {
@ -132,10 +133,6 @@ html:root[data-yomichan-page=float] .navigation-header {
margin-right: 0.2em; margin-right: 0.2em;
} }
html:root[data-yomichan-page=search] body {
overflow-y: scroll; /* always show scroll bar to avoid scanning problems */
}
/* /*
* Entries * Entries

View File

@ -372,16 +372,18 @@ class Display {
this.updateNavigation(this.context.previous, this.context.next); this.updateNavigation(this.context.previous, this.context.next);
this.setNoContentVisible(definitions.length === 0); this.setNoContentVisible(definitions.length === 0);
const fragment = document.createDocumentFragment(); const container = this.container;
for (const definition of definitions) { container.textContent = '';
fragment.appendChild(this.displayGenerator.createTermEntry(definition));
for (let i = 0, ii = definitions.length; i < ii; ++i) {
if (i > 0) {
await promiseTimeout(1);
if (this.setContentToken !== token) { return; }
} }
await Promise.resolve(); // Delay to help avoid forced reflow warnings in Chrome const entry = this.displayGenerator.createTermEntry(definitions[i]);
if (this.setContentToken !== token) { return; } container.appendChild(entry);
}
this.container.textContent = '';
this.container.appendChild(fragment);
const {index, scroll, disableScroll} = context; const {index, scroll, disableScroll} = context;
if (!disableScroll) { if (!disableScroll) {
@ -429,16 +431,18 @@ class Display {
this.updateNavigation(this.context.previous, this.context.next); this.updateNavigation(this.context.previous, this.context.next);
this.setNoContentVisible(definitions.length === 0); this.setNoContentVisible(definitions.length === 0);
const fragment = document.createDocumentFragment(); const container = this.container;
for (const definition of definitions) { container.textContent = '';
fragment.appendChild(this.displayGenerator.createKanjiEntry(definition));
for (let i = 0, ii = definitions.length; i < ii; ++i) {
if (i > 0) {
await promiseTimeout(0);
if (this.setContentToken !== token) { return; }
} }
await Promise.resolve(); // Delay to help avoid forced reflow warnings in Chrome const entry = this.displayGenerator.createKanjiEntry(definitions[i]);
if (this.setContentToken !== token) { return; } container.appendChild(entry);
}
this.container.textContent = '';
this.container.appendChild(fragment);
const {index, scroll} = context; const {index, scroll} = context;
this.entryScrollIntoView(index || 0, scroll); this.entryScrollIntoView(index || 0, scroll);