render at least 10 style entries on slower machines

This commit is contained in:
tophf 2017-04-19 23:54:05 +03:00
parent 3a8ac2d9dc
commit a80c677b3e
2 changed files with 4 additions and 5 deletions

View File

@ -204,7 +204,7 @@ rules:
no-undefined: [0] no-undefined: [0]
no-underscore-dangle: [0] no-underscore-dangle: [0]
no-unexpected-multiline: [2] no-unexpected-multiline: [2]
no-unmodified-loop-condition: [2] no-unmodified-loop-condition: [1]
no-unneeded-ternary: [2] no-unneeded-ternary: [2]
no-unreachable: [2] no-unreachable: [2]
no-unsafe-finally: [2] no-unsafe-finally: [2]

View File

@ -104,11 +104,10 @@ function showStyles(styles = []) {
function renderStyles(index) { function renderStyles(index) {
const t0 = performance.now(); const t0 = performance.now();
while (index < sorted.length) { let rendered = 0;
while (index < sorted.length
&& (shouldRenderAll || performance.now() - t0 < 10 || ++rendered < 10)) {
renderBin.appendChild(createStyleElement(sorted[index++])); renderBin.appendChild(createStyleElement(sorted[index++]));
if (!shouldRenderAll && performance.now() - t0 > 10) {
break;
}
} }
filterAndAppend({container: renderBin}); filterAndAppend({container: renderBin});
if (index < sorted.length) { if (index < sorted.length) {