Skip to content

Commit 849e791

Browse files
szuendDevtools-frontend LUCI CQ
authored andcommitted
[ui] Use .querySelectorAll for linkElements
The only user is the ConsoleViewMessage to get the correct order when Tab-bing through the stack trace. With .querySelectorAll, we safe the usage of refs and a view output when migrating to Lit. Drive-by: Links are no longer optional. We always output one. R=pfaffe@chromium.org Bug: 483576322 Change-Id: Ie5496f73f98728263289cacd9a0099b6931e0a97 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7587937 Reviewed-by: Philip Pfaffe <pfaffe@chromium.org> Commit-Queue: Simon Zünd <szuend@chromium.org>
1 parent 3083232 commit 849e791

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

front_end/ui/legacy/components/utils/JSPresentationUtils.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,8 @@ function buildStackTraceRows(
142142

143143
function renderStackTraceTable(
144144
container: Element, parent: Element, expandable: boolean,
145-
stackTraceRows: Array<StackTraceRegularRow|StackTraceAsyncRow>): HTMLElement[] {
145+
stackTraceRows: Array<StackTraceRegularRow|StackTraceAsyncRow>): void {
146146
container.removeChildren();
147-
const links: HTMLElement[] = [];
148147

149148
// The tableSection groups one or more synchronous call frames together.
150149
// Wherever there is an asynchronous call, a new section is created.
@@ -178,10 +177,7 @@ function renderStackTraceTable(
178177
} else {
179178
row.createChild('td', 'function-name').textContent = item.functionName;
180179
row.createChild('td').textContent = ' @ ';
181-
if (item.link) {
182-
row.createChild('td', 'link').appendChild(item.link);
183-
links.push(item.link);
184-
}
180+
row.createChild('td', 'link').appendChild(item.link);
185181
}
186182
}
187183

@@ -214,8 +210,6 @@ function renderStackTraceTable(
214210
// If we are in a popup, this will trigger a re-layout
215211
UI.GlassPane.GlassPane.containerMoved(container);
216212
}, false);
217-
218-
return links;
219213
}
220214

221215
export interface Options {
@@ -230,7 +224,7 @@ export interface Options {
230224

231225
interface StackTraceRegularRow {
232226
functionName: string;
233-
link: HTMLElement|null;
227+
link: HTMLElement;
234228
}
235229

236230
interface StackTraceAsyncRow {
@@ -240,7 +234,6 @@ interface StackTraceAsyncRow {
240234
export class StackTracePreviewContent extends UI.Widget.Widget {
241235
#stackTrace?: StackTrace.StackTrace.StackTrace;
242236
#options: Options = {};
243-
#links: HTMLElement[] = [];
244237

245238
readonly #table: HTMLElement;
246239

@@ -267,11 +260,11 @@ export class StackTracePreviewContent extends UI.Widget.Widget {
267260

268261
const stackTraceRows =
269262
buildStackTraceRows(this.#stackTrace, this.#options.tabStops, this.#options.showColumnNumber);
270-
this.#links = renderStackTraceTable(this.#table, this.element, this.#options.expandable ?? false, stackTraceRows);
263+
renderStackTraceTable(this.#table, this.element, this.#options.expandable ?? false, stackTraceRows);
271264
}
272265

273266
get linkElements(): readonly HTMLElement[] {
274-
return this.#links;
267+
return [...this.contentElement.querySelectorAll<HTMLElement>('td.link > .devtools-link')];
275268
}
276269

277270
set options(options: Options) {

0 commit comments

Comments
 (0)