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

Steps of removing a node definition about live range do not match with browsers if the range is in a shadow DOM and the shadow itself is removed #1274

Open
masayuki-nakano opened this issue Apr 4, 2024 · 4 comments

Comments

@masayuki-nakano
Copy link

What is the issue with the DOM Standard?

https://dom.spec.whatwg.org/#concept-node-remove

  1. For each live range whose start node is an inclusive descendant of node, set its start to (parent, index).
  2. For each live range whose end node is an inclusive descendant of node, set its end to (parent, index).

"inclusive descendant" is defined as:
https://dom.spec.whatwg.org/#concept-tree-inclusive-descendant

An object A is called a descendant of an object B, if either A is a child of B or A is a child of an object C that is a descendant of B.
An inclusive descendant is an object or one of its descendants.

Although the latter definition does not mention about shadow DOM boundaries, these definitions sound like that when a shadow containing a live range is deleted, the range is collapsed at the removed node position in the parent (or ancestor) tree. I wrote a test for this and now merged into the WPT tree that expects that Range is not collapsed to outside the shadow DOM tree. Then, all browsers now pass all tests.

So I think that the former definition should mention about that when the live range is in a subtree, removable of inclusive ancestor of the host does not affect to the range.

Cc: @sefeng211, @smaug----, @zcorpan

@annevk
Copy link
Member

annevk commented Apr 9, 2024

cc @mfreed7 @domfarolino

@smaug----
Copy link
Collaborator

See also w3c/selection-api#168

@dizhang168
Copy link

An inclusive descendant is an object or one of its descendants.
An object A is called a descendant of an object B, if either A is a child of B or A is a child of an object C that is a descendant of B.

vs

A shadow-including inclusive descendant is an object or one of its shadow-including descendants.
An object A is a shadow-including descendant of an object B, if A is a descendant of B, or A’s root is a shadow root and A’s root’s host is a shadow-including inclusive descendant of B.

spec source

My understanding of the spec is that since the above Node remove steps are for "inclusive descendants", they should be scoped to be within the tree scope and not cross shadow trees. I don't think the steps need to mention shadow host specific behavior.

@annevk
Copy link
Member

annevk commented Oct 19, 2024

@masayuki-nakano I think I agree with @dizhang168 that the current specification is okay for the scenario you wrote a test for. What exactly do you think is wrong?

(There's certainly issues when the selection crosses the boundary, but that's a separate topic.)

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

No branches or pull requests

4 participants