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

issues with optionality of oldParent in HTML element removing steps, particularly with removal of optgroups #9390

Closed
dbaron opened this issue Jun 6, 2023 · 1 comment · Fixed by #9434

Comments

@dbaron
Copy link
Member

dbaron commented Jun 6, 2023

I'm currently working on a PR to HTML where I was considering defining HTML element removing steps. When the DOM specification defines the concept of remove, it invokes removing steps twice: in step 15 with the node being removed and its old parent, and in step 18.1 with each descendant of the node being removed (but no parent passed). This matches both the DOM specifications concept of removing steps and the HTML specification's concept of HTML element removing steps which both describe the oldParent variable as optional.

I think this shows two problems in the HTML standard:

  1. all of the places that currently define "HTML element removing steps", in particular for source, for img, and for option should describe the oldParent variable as optional, which they do not currently do.
  2. The HTML element removing steps for option appear not to do what it look like they do on a simple reading. In particular, I believe these steps do not handle the removal of an optgroup element whose child is an option element the way they ought to, since they do not invoke the select element's selectedness setting algorithm. I believe this is fixable by also adding HTML element removal steps for optgroup. I have not tested implementations to see if they match such a change, although I hope that they do!

(I believe both of the issues above could be fixed straightforwardly as described. However, I'd add that these fixes wouldn't help me with my issue, since I actually would like to access the root of the tree as it was prior to the removal, including for descendants, which this definition doesn't allow. I'm trying to write a PR for exclusive accordion in a way that properly defines the order of mutation of open attributes, which is web-observable only thanks to mutation events. Given that mutation events are deprecated, I'd prefer not to use tree order (which is more expensive), but instead want to use insertion order, but that seems to require maintaining a data structure of the relevant details elements using insertion and removal steps. Given the above, this appears not to be possible, so I'm still stuck on this for now.)

@annevk
Copy link
Member

annevk commented Jun 16, 2023

Per http://software.hixie.ch/utilities/js/live-dom-viewer/saved/11803 that appears correct. See #9434 for a possible fix. Feedback appreciated!

annevk added a commit that referenced this issue Aug 25, 2023
This builds on whatwg/dom#1210 and together they fix #9390.
annevk added a commit that referenced this issue Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants