Skip to content

Commit

Permalink
PageSnapshot: reduce cloning loop iterations (#669)
Browse files Browse the repository at this point in the history
Follow-up to #666

Following [a suggestion][] provided by review of #666, this commit
remove unnecessary loops when cloning a page's form controls to be
cached by a snapshot.

[a suggestion]: #666 (comment)
  • Loading branch information
seanpdoyle authored Aug 8, 2022
1 parent 4d329ab commit c4e0aba
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core/drive/page_snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export class PageSnapshot extends Snapshot<HTMLBodyElement> {
const clonedSelectElements = clonedElement.querySelectorAll("select")

for (const [index, source] of selectElements.entries()) {
for (const [optionIndex, option] of Array.from(source.options).entries()) {
clonedSelectElements[index].options[optionIndex].selected = option.selected
}
const clone = clonedSelectElements[index]
for (const option of clone.selectedOptions) option.selected = false
for (const option of source.selectedOptions) clone.options[option.index].selected = true
}

for (const clonedPasswordInput of clonedElement.querySelectorAll<HTMLInputElement>('input[type="password"]')) {
Expand Down

0 comments on commit c4e0aba

Please sign in to comment.