Skip to content

Commit

Permalink
jQuery workloads: use :nth-child() in a querySelector call in each it…
Browse files Browse the repository at this point in the history
…eration (#367)

This PR fixes the issue #365: jQuery test only ever marks the first todo item as completed

The bug was caused by jQuery replacing the whole todo list whenever each todo item is toggled.

Fixed it by running querySelector with :nth-child in each iteration.

Co-authored-by: Ryosuke Niwa <rniwa@webkit.org>
  • Loading branch information
julienw and rniwa authored Feb 8, 2024
1 parent 9837ccc commit 0fd1528
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions resources/tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -566,9 +566,8 @@ Suites.push({
}
}),
new BenchmarkTestStep("CompletingAllItems", (page) => {
const checkboxes = page.querySelectorAll(".toggle");
for (let i = 0; i < numberOfItemsToAdd; i++)
checkboxes[i].click();
for (let i = 1; i <= numberOfItemsToAdd; i++)
page.querySelector(`li:nth-child(${i}) .toggle`).click();
}),
new BenchmarkTestStep("DeletingAllItems", (page) => {
for (let i = numberOfItemsToAdd - 1; i >= 0; i--)
Expand Down Expand Up @@ -596,9 +595,8 @@ Suites.push({
}
}),
new BenchmarkTestStep("CompletingAllItems", (page) => {
const checkboxes = page.querySelectorAll(".toggle");
for (let i = 0; i < numberOfItemsToAdd; i++)
checkboxes[i].click();
for (let i = 1; i <= numberOfItemsToAdd; i++)
page.querySelector(`li:nth-child(${i}) .toggle`).click();
}),
new BenchmarkTestStep("DeletingAllItems", (page) => {
for (let i = numberOfItemsToAdd - 1; i >= 0; i--)
Expand Down

0 comments on commit 0fd1528

Please sign in to comment.