-
Notifications
You must be signed in to change notification settings - Fork 30
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
Specify the behavior when DOM mutation occurs across shadow-crossing selection #168
Comments
I think this is essentially what I mentioned in #161 (comment) which references WICG/webcomponents#79 (comment). Let's think about this a bit:
@mfreed7 @rniwa @smaug---- thoughts? |
Similar to my reply on #79, I agree. Your summary above sounds exactly right to me. The devil is in the details, but the broad strokes look correct.
Seems like that operation (manipulation of a live range) should go through the same "update selection" algorithm which should take care of the details. |
That would mean we have multiple ranges associated with the selection representing the same conceptual range within the selection. Maybe instead the "public selection live range" ( The most difficult part here is probably defining the "selection live range". |
That is the tricky bit. Not only we need to handle mutations in one tree but I believe also changes to slotting should affect selection. |
I wrote a test to check the behavior of a selection range which is in a shadow DOM and after the host is removed. Currently, Chrome keeps the range as a selection range without modifying the range in the shadow. Firefox removes the range from I changed the Firefox's behavior as so for consistency with whatwg/dom#1274 and #175, but could be reasonable to make the selection range cloned (to avoid unexpected range update for the referrers of the |
In your test, you are checking the effect of removing the Shadow host when the Live Range of the current selection is inside the shadow root. For the Selection's Live Range, I believe Chrome is doing the specced behavior. The range should stay within the shadow root's tree scope, even when the the host is removed. No collapsing and boundary points need to be changed. For the Selection's Composed Range (not defined yet, but this is not the output of getRangeAt), we can compare ancestors while crossing the shadow boundaries. In this case, I would expect the behavior Safari is doing. I added more tests for the new getComposedRanges() API. |
Agenda+ this issue. |
Editing WG Nov 14, 2024 IRC notes: Specify composed range and mutation behavior in DOM spec08:20 next issue: #168 Update DOM spec by adding details for composed range
Add: For each composed range whose start node is a shadow-inclusive descendant of node, set its start to (parent, index). We could also refactor the DOM specification with a new “Update Selection” algorithm. @annevk @sanketj @smaug---- for reference |
We should specify the behavior when DOM trees are mutated (e.g. shadow host is removed) when selection cross shadow boundaries.
The text was updated successfully, but these errors were encountered: