Skip to content

Commit ff425b2

Browse files
josepharharchromium-wpt-export-bot
authored andcommittedOct 31, 2024·
Make <selectedoption> stop responding to mutations
This patch makes <selectedoption> stop using the MutationObserver for <option>: openui/open-ui#825 This patch also uncovered a small bug with the selectedoptionelement attribute when assigning null to the IDL attribute, which I fixed by removing a null check. Bug: 336844298 Change-Id: I3fed171bf687cabb9474d8ff8741071c28bbad0b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5941575 Reviewed-by: Dominic Farolino <dom@chromium.org> Commit-Queue: Joey Arhar <jarhar@chromium.org> Cr-Commit-Position: refs/heads/main@{#1376573}
1 parent d7b8dae commit ff425b2

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed
 

‎html/semantics/forms/the-select-element/customizable-select/selectedoption.tentative.html

+9-6
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,21 @@
4444
assert_equals(selectedOption.innerHTML, optionTwo.innerHTML,
4545
'The innerHTML of <selectedoption> should change after the selected option is changed.');
4646

47+
let oldInnerHTML = optionTwo.innerHTML;
4748
spanTwo.textContent = 'new span';
4849
await new Promise(queueMicrotask);
49-
assert_equals(selectedOption.innerHTML, optionTwo.innerHTML,
50-
'<selectedoption> should respond to text content changes.');
50+
assert_equals(selectedOption.innerHTML, oldInnerHTML,
51+
'<selectedoption> should not respond to <option> text content changes.');
5152

5253
spanTwo.appendChild(document.createElement('div'));
5354
await new Promise(queueMicrotask);
54-
assert_equals(selectedOption.innerHTML, optionTwo.innerHTML,
55-
'<selectedoption> should respond to new elements being added to descendants.');
55+
assert_equals(selectedOption.innerHTML, oldInnerHTML,
56+
'<selectedoption> should not respond to new elements being added to descendants of <option>.');
5657

5758
spanTwo.setAttribute('data-foo', 'bar');
5859
await new Promise(queueMicrotask);
59-
assert_equals(selectedOption.innerHTML, optionTwo.innerHTML,
60-
'<selectedoption> should respond to attributes being added to descendants.');
60+
assert_equals(selectedOption.innerHTML, oldInnerHTML,
61+
'<selectedoption> should not respond to attributes being added to descendants of <option>.');
6162

6263
form.reset();
6364
await new Promise(queueMicrotask);
@@ -90,5 +91,7 @@
9091
optionOne.remove();
9192
assert_equals(selectedOption.innerHTML, '',
9293
'The content of <selectedoption> should be cleared if there is no selected <option>.');
94+
95+
// TODO(crbug.com/336844298): Add tests for mutation records during parsing
9396
}, 'The <selectedoption> element should reflect the HTML contents of the selected <option>.');
9497
</script>

‎html/semantics/forms/the-select-element/customizable-select/selectedoptionelement-attr.tentative.html

+5-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@
3434
'Removing the selectedoptionelement attribute via IDL should synchronously clear the contents of the <selectedoption>.');
3535

3636
select.selectedOptionElement = selectedoption;
37+
assert_equals(selectedoption.innerHTML, optionOne.innerHTML,
38+
'Re-setting the selectedoptionelement attribute via IDL should synchronously assign the contents of <selectedoption>.');
3739

40+
let oldInnerHTML = optionOne.innerHTML;
3841
optionOne.querySelector('span').remove();
3942
await new Promise(queueMicrotask);
40-
assert_equals(selectedoption.innerHTML, optionOne.innerHTML,
41-
'Mutating the selected <option> should update the <selectedoption> contents after a microtask.');
43+
assert_equals(selectedoption.innerHTML, oldInnerHTML,
44+
'Mutating the selected <option> should not update the <selectedoption> contents.');
4245

4346
select.value = 'two';
4447
assert_equals(selectedoption.innerHTML, optionTwo.innerHTML,

0 commit comments

Comments
 (0)
Please sign in to comment.