Skip to content

Conversation

josepharhar
Copy link
Contributor

@josepharhar josepharhar commented Oct 14, 2025

This PR improves the option element insertion and removal steps to incorporate invalid nestings of option elements inside select elements by reusing the nearest ancestor select algorithm. It also adds datalist to the list of disallowed elements for nesting options in.

Fixes #11787

(See WHATWG Working Mode: Changes for more details.)


/form-elements.html ( diff )

This PR improves the option element insertion and removal steps to
incorporate invalid nestings of option elements inside select elements
by reusing the nearest ancestor select algorithm. It also adds datalist
to the list of disallowed elements for nesting options in.

Fixes whatwg#11787
Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this works and avoids a lot of the complexity I was envisioning we'd need. Nice!

@annevk
Copy link
Member

annevk commented Oct 15, 2025

We also need to account for this where we look for whether option is disabled.

@annevk
Copy link
Member

annevk commented Oct 15, 2025

html/semantics/forms/the-select-element/customizable-select/nested-options.tenative.html also needs to be updated.

Here's a proposed patch:

index 0cecdf224b1a..89d5b874704b 100644
--- a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/customizable-select/nested-options.tenative.html
+++ b/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/customizable-select/nested-options.tenative.html
@@ -33,6 +33,7 @@ test(() => {
 
 // Manually nest the <options> anyway for the following tests.
 o1.appendChild(o2);
+document.querySelector('select').appendChild(o1);
 
 test(() => {
   assert_equals(select.options.length, 1, 'select.options.length');

@annevk
Copy link
Member

annevk commented Oct 15, 2025

Another comment: the moving steps can now call this update algorithm directly. The way this is currently written it'd run a lot of redundant code.

@josepharhar
Copy link
Contributor Author

html/semantics/forms/the-select-element/customizable-select/nested-options.tenative.html also needs to be updated.

Here's a proposed patch:

Thanks, I am incorporating this into the chromium patch in the PR description.

We also need to account for this where we look for whether option is disabled.

Thanks, I accounted for this and added a test to the WPT changes

Another comment: the moving steps can now call this update algorithm directly. The way this is currently written it'd run a lot of redundant code.

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

make datalist an early return for the option insertion/removing steps

2 participants