Skip to content

Commit 412f220

Browse files
danilsomsikovDevtools-frontend LUCI CQ
authored andcommitted
Support adding extra children to the empty widget.
This should have been a slot, but we have too many tests relying on EmptyWidget having no shadow DOM. Bug: 407751409 Change-Id: Ic20881465ce1b37b363f21af776def398535c309 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7022429 Auto-Submit: Danil Somsikov <dsv@chromium.org> Reviewed-by: Philip Pfaffe <pfaffe@chromium.org> Commit-Queue: Danil Somsikov <dsv@chromium.org> Commit-Queue: Philip Pfaffe <pfaffe@chromium.org>
1 parent 05f82da commit 412f220

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

front_end/ui/legacy/EmptyWidget.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ interface EmptyWidgetInput {
2626
header: string;
2727
text: string;
2828
link?: Platform.DevToolsPath.UrlString|undefined|null;
29+
extraElements?: Element[];
2930
}
3031

3132
interface EmptyWidgetOutput {
@@ -47,6 +48,7 @@ const DEFAULT_VIEW: View = (input, output, target) => {
4748
${input.link ? XLink.create(
4849
input.link, i18nString(UIStrings.learnMore), undefined, undefined, 'learn-more') : ''}
4950
</div>
51+
${input.extraElements}
5052
</div>`, target);
5153
// clang-format on
5254
};
@@ -56,6 +58,8 @@ export class EmptyWidget extends VBox {
5658
#text: string;
5759
#link: Platform.DevToolsPath.UrlString|undefined|null;
5860
#view: View;
61+
#firstUpdate = true;
62+
#extraElements: Element[] = [];
5963

6064
constructor(headerOrElement: string|HTMLElement, text = '', element?: HTMLElement, view = DEFAULT_VIEW) {
6165
const header = typeof headerOrElement === 'string' ? headerOrElement : '';
@@ -86,8 +90,14 @@ export class EmptyWidget extends VBox {
8690
}
8791

8892
override performUpdate(): void {
93+
if (this.#firstUpdate) {
94+
this.#extraElements = [...this.element.children];
95+
this.#firstUpdate = false;
96+
}
8997
const output = {contentElement: undefined};
90-
this.#view({header: this.#header, text: this.#text, link: this.#link}, output, this.element);
98+
this.#view(
99+
{header: this.#header, text: this.#text, link: this.#link, extraElements: this.#extraElements}, output,
100+
this.element);
91101
if (output.contentElement) {
92102
this.contentElement = output.contentElement;
93103
}

0 commit comments

Comments
 (0)