Merge pull request #12796 from Snuffleupagus/BaseTreeViewer._finishRendering

Extract common functionality into a new `BaseTreeViewer._finishRendering` method
This commit is contained in:
Tim van der Meij 2020-12-30 14:05:21 +01:00 committed by GitHub
commit 6e55326343
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 21 deletions

View File

@ -103,6 +103,20 @@ class BaseTreeViewer {
this._toggleTreeItem(this.container, !this._lastToggleIsShow); this._toggleTreeItem(this.container, !this._lastToggleIsShow);
} }
/**
* @private
*/
_finishRendering(fragment, count, hasAnyNesting = false) {
if (hasAnyNesting) {
this.container.classList.add("treeWithDeepNesting");
this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
}
this.container.appendChild(fragment);
this._dispatchEvent(count);
}
render(params) { render(params) {
throw new Error("Not implemented: render"); throw new Error("Not implemented: render");
} }

View File

@ -187,9 +187,7 @@ class PDFAttachmentViewer extends BaseTreeViewer {
attachmentsCount++; attachmentsCount++;
} }
this.container.appendChild(fragment); this._finishRendering(fragment, attachmentsCount);
this._dispatchEvent(attachmentsCount);
} }
/** /**

View File

@ -174,16 +174,8 @@ class PDFLayerViewer extends BaseTreeViewer {
levelData.parent.appendChild(div); levelData.parent.appendChild(div);
} }
} }
if (hasAnyNesting) {
this.container.classList.add("treeWithDeepNesting");
this._lastToggleIsShow = this._finishRendering(fragment, layersCount, hasAnyNesting);
fragment.querySelectorAll(".treeItemsHidden").length === 0;
}
this.container.appendChild(fragment);
this._dispatchEvent(layersCount);
} }
/** /**

View File

@ -171,16 +171,8 @@ class PDFOutlineViewer extends BaseTreeViewer {
outlineCount++; outlineCount++;
} }
} }
if (hasAnyNesting) {
this.container.classList.add("treeWithDeepNesting");
this._lastToggleIsShow = this._finishRendering(fragment, outlineCount, hasAnyNesting);
fragment.querySelectorAll(".treeItemsHidden").length === 0;
}
this.container.appendChild(fragment);
this._dispatchEvent(outlineCount);
} }
} }