Closed
Bug 1442305
Opened 7 years ago
Closed 7 years ago
setFilterState() in head.js fails when setting multiple categories
Categories
(DevTools :: Console, enhancement, P1)
DevTools
Console
Tracking
(firefox60 fixed)
RESOLVED
FIXED
Firefox 60
| Tracking | Status | |
|---|---|---|
| firefox60 | --- | fixed |
People
(Reporter: miker, Assigned: miker)
References
Details
Attachments
(1 file)
setFilterState() in head.js returns early when setting multiple categories if no change is needed and we are setting multiple categories.
Basically, I used return in a loop when I should have used a continue.
| Assignee | ||
Updated•7 years ago
|
Has Regression Range: --- → irrelevant
Has STR: --- → irrelevant
| Comment hidden (mozreview-request) |
Comment 2•7 years ago
|
||
| mozreview-review | ||
Comment on attachment 8955202 [details]
Bug 1442305 - setFilterState() in head.js fails when setting multiple categories
https://reviewboard.mozilla.org/r/224366/#review230562
::: devtools/client/webconsole/new-console-output/test/mochitest/head.js:673
(Diff revision 1)
> if (check) {
> // Enable filter.
> if (checked) {
> - return;
> + continue;
> }
> button.click();
> await waitFor(() => {
> return button.classList.contains("checked");
> });
> } else if (checked) {
> // Disable filter.
> button.click();
> await waitFor(() => {
> return !button.classList.contains("checked");
> });
> }
I find `continue` statement hard to read, you need to go up see which loop you're in and you can lose track of what the code is doing.
Could we reorder things a bit so it's more clear what is done ?
```js
// If the button isn't already in the state we want.
if (check !== buttonIsChecked) {
button.click();
await waitFor(() =>
button.classList.contains("checked") === check);
}
```
What do you think of this ?
| Assignee | ||
Comment 3•7 years ago
|
||
| mozreview-review | ||
Comment on attachment 8955202 [details]
Bug 1442305 - setFilterState() in head.js fails when setting multiple categories
https://reviewboard.mozilla.org/r/224366/#review230618
::: devtools/client/webconsole/new-console-output/test/mochitest/head.js:673
(Diff revision 1)
> if (check) {
> // Enable filter.
> if (checked) {
> - return;
> + continue;
> }
> button.click();
> await waitFor(() => {
> return button.classList.contains("checked");
> });
> } else if (checked) {
> // Disable filter.
> button.click();
> await waitFor(() => {
> return !button.classList.contains("checked");
> });
> }
Yup... not sure what I was thinking.
| Assignee | ||
Comment 4•7 years ago
|
||
| mozreview-review-reply | ||
Comment on attachment 8955202 [details]
Bug 1442305 - setFilterState() in head.js fails when setting multiple categories
https://reviewboard.mozilla.org/r/224366/#review230562
> I find `continue` statement hard to read, you need to go up see which loop you're in and you can lose track of what the code is doing.
>
> Could we reorder things a bit so it's more clear what is done ?
>
> ```js
> // If the button isn't already in the state we want.
> if (check !== buttonIsChecked) {
> button.click();
> await waitFor(() =>
> button.classList.contains("checked") === check);
> }
> ```
>
> What do you think of this ?
Makes way more sense... not sure what I was thinking.
| Comment hidden (mozreview-request) |
Comment 6•7 years ago
|
||
| mozreview-review | ||
Comment on attachment 8955202 [details]
Bug 1442305 - setFilterState() in head.js fails when setting multiple categories
https://reviewboard.mozilla.org/r/224366/#review230644
Looks good, thanks for addressing the comment Mike
Attachment #8955202 -
Flags: review?(nchevobbe) → review+
Pushed by mratcliffe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/705748b426e1
setFilterState() in head.js fails when setting multiple categories r=nchevobbe
Comment 8•7 years ago
|
||
| bugherder | ||
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
status-firefox60:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 60
Updated•7 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•