Skip to content

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

@dbaron

Description

@dbaron

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.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions