Closed Bug 1617672 Opened 4 years ago Closed 4 years ago

Avoid outputting filter category as an unprefixed class on filter buttons

Categories

(DevTools :: Console, task, P3)

task

Tracking

(firefox75 fixed)

RESOLVED FIXED
Firefox 75
Tracking Status
firefox75 --- fixed

People

(Reporter: fvsch, Assigned: i, Mentored)

Details

(Keywords: good-first-bug)

Attachments

(1 file, 1 obsolete file)

We're generating this DOM for filter buttons:

<button aria-pressed="true" class="devtools-togglebutton error">
  Errors
</button>

where the second class is one of these values:

const FILTERS = {
  CSS: "css",
  DEBUG: "debug",
  ERROR: "error",
  INFO: "info",
  LOG: "log",
  NET: "net",
  NETXHR: "netxhr",
  TEXT: "text",
  WARN: "warn",
};

This means we have elements with super generic classes like "error", "info", "log", or "text", and any somewhat rogue style that would target one of these could break the toolbar styles.

On top of that, those classes are awkward to work with:

/* devtools/client/webconsole/test/browser/head.js#getFilterState */
for (const button of buttons) {
  const classes = new Set(button.classList.values());
  classes.delete("devtools-togglebutton");
  const category = classes.values().next().value;
  result[category] = button.getAttribute("aria-pressed") === "true";
}

We could use a data attribute instead:

<button aria-pressed="true" class="devtools-togglebutton" data-category="error">
  Errors
</button>

which simplifies the above code:

for (const button of buttons) {
  result[button.dataset.category] = button.getAttribute("aria-pressed") === "true";
}

Thanks for filing Florens, I totally agree with you.

Mentor: nchevobbe
Keywords: good-first-bug
Priority: -- → P3
Assignee: nobody → i
Status: NEW → ASSIGNED
Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/3eb6676c83ad
Avoid outputting filter category as an unprefixed class on filter buttons. r=nchevobbe
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 75
Attachment #9129365 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: