Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make <selectedoption> stop responding to mutations #48913

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,21 @@
assert_equals(selectedOption.innerHTML, optionTwo.innerHTML,
'The innerHTML of <selectedoption> should change after the selected option is changed.');

let oldInnerHTML = optionTwo.innerHTML;
spanTwo.textContent = 'new span';
await new Promise(queueMicrotask);
assert_equals(selectedOption.innerHTML, optionTwo.innerHTML,
'<selectedoption> should respond to text content changes.');
assert_equals(selectedOption.innerHTML, oldInnerHTML,
'<selectedoption> should not respond to <option> text content changes.');

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

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

form.reset();
await new Promise(queueMicrotask);
Expand Down Expand Up @@ -90,5 +91,7 @@
optionOne.remove();
assert_equals(selectedOption.innerHTML, '',
'The content of <selectedoption> should be cleared if there is no selected <option>.');

// TODO(crbug.com/336844298): Add tests for mutation records during parsing
}, 'The <selectedoption> element should reflect the HTML contents of the selected <option>.');
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@
'Removing the selectedoptionelement attribute via IDL should synchronously clear the contents of the <selectedoption>.');

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

let oldInnerHTML = optionOne.innerHTML;
optionOne.querySelector('span').remove();
await new Promise(queueMicrotask);
assert_equals(selectedoption.innerHTML, optionOne.innerHTML,
'Mutating the selected <option> should update the <selectedoption> contents after a microtask.');
assert_equals(selectedoption.innerHTML, oldInnerHTML,
'Mutating the selected <option> should not update the <selectedoption> contents.');

select.value = 'two';
assert_equals(selectedoption.innerHTML, optionTwo.innerHTML,
Expand Down