Skip to content

Commit c24f4fb

Browse files
Improve <selectedoption> performance
This patch improves the performance of <selectedoption> by replacing the SynchronousMutationObserver with the existing async MutationObserver in HTMLOptionElement. The change from sync to async impacts some tests. The timing is being discussed in a standards issue here: whatwg/html#10520 Fixed: 336844298 Change-Id: I9693de9cf35913e7daaebb364c4923dcd4a2dc39 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5758741 Reviewed-by: Mason Freed <[email protected]> Commit-Queue: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1337462}
1 parent bb8a129 commit c24f4fb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

html/semantics/forms/the-select-element/stylable-select/selectedoption.tentative.html

+8
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,27 @@
3636
'The innerHTML of <selectedoption> should initially match the innerHTML of the selected <option>.');
3737

3838
select.value = 'two';
39+
await new Promise(queueMicrotask);
3940
assert_equals(selectedOption.innerHTML, optionTwo.innerHTML,
4041
'The innerHTML of <selectedoption> should change after the selected option is changed.');
4142

4243
spanTwo.textContent = 'new span';
44+
await new Promise(queueMicrotask);
4345
assert_equals(selectedOption.innerHTML, optionTwo.innerHTML,
4446
'<selectedoption> should respond to text content changes.');
4547

4648
spanTwo.appendChild(document.createElement('div'));
49+
await new Promise(queueMicrotask);
4750
assert_equals(selectedOption.innerHTML, optionTwo.innerHTML,
4851
'<selectedoption> should respond to new elements being added to descendants.');
4952

5053
spanTwo.setAttribute('data-foo', 'bar');
54+
await new Promise(queueMicrotask);
5155
assert_equals(selectedOption.innerHTML, optionTwo.innerHTML,
5256
'<selectedoption> should respond to attributes being added to descendants.');
5357

5458
form.reset();
59+
await new Promise(queueMicrotask);
5560
assert_equals(select.value, 'one',
5661
'form.reset() should change the selects value to one.');
5762
assert_equals(selectedOption.innerHTML, optionOne.innerHTML,
@@ -60,19 +65,22 @@
6065
await test_driver.bless();
6166
select.showPicker();
6267
await test_driver.click(optionTwo);
68+
await new Promise(queueMicrotask);
6369
assert_equals(select.value, 'two',
6470
'Clicking on another option should change select.value.');
6571
assert_equals(selectedOption.innerHTML, optionTwo.innerHTML,
6672
'Clicking on an option element should update the <selectedoption>.');
6773

6874
selectedOption.remove();
75+
await new Promise(queueMicrotask);
6976
assert_equals(selectedOption.innerHTML, '',
7077
'Removing the <selectedoption> from the <select> should make it clear its contents.');
7178
button.appendChild(selectedOption);
7279
assert_equals(selectedOption.innerHTML, optionTwo.innerHTML,
7380
'Re-inserting the <selectedoption> should make it update its contents.');
7481

7582
optionTwo.remove();
83+
await new Promise(queueMicrotask);
7684
assert_equals(selectedOption.innerHTML, optionOne.innerHTML,
7785
'The innerHTML of <selectedoption> should be updated in response to selected <option> removal.');
7886
optionOne.remove();

0 commit comments

Comments
 (0)