w3c / selection-api

Selection API
http://w3c.github.io/selection-api/
Other
47 stars 30 forks source link

Change `getComposedRanges`'s `shadowRoots` parameter from rest parameter to a dictionary #176

Closed siliu1 closed 1 month ago

siliu1 commented 6 months ago

Current spec of getComposedRanges API has single shadowRoots parameter which is a rest parameter. We should change it to a dictionary that contains an array of shadow roots. Similar to https://html.spec.whatwg.org/#gethtmloptions. It'd be good to be consistent.

Proposed change:

sequence<StaticRange> getComposedRanges(optional GetComposedRangesOptions options = {});

dictionary GetComposedRangesOptions {
  sequence<ShadowRoot> shadowRoots = [];
};
siliu1 commented 6 months ago

@mfreed7 FYI.

mfreed7 commented 6 months ago

@mfreed7 FYI.

LGTM! Thanks.

smaug---- commented 6 months ago

The API has shipped already in webkit, right?

@sefeng211

mfreed7 commented 6 months ago

I think that's a prototype implementation, though, right? The spec hasn't been reviewed by another implementer that I know of. Or perhaps Mozilla did?

Anyway, this seems reasonable. We will now have this pattern three places, getHTML(), caretPositionFromPoint(), and here with getComposedRanges() - it would be good if they all followed the same pattern.

sefeng211 commented 6 months ago

Yeah it's shipped in Webkit. cc @rniwa

dizhang168 commented 4 months ago

Even though Webkit has shipped getComposedRanges, this question is still unanswered. @rniwa @sefeng211 What do you think of this proposal?

sefeng211 commented 3 months ago

Looks reasonable to me

sanketj commented 3 months ago

@johanneswilm Can we add this to the agenda for the next Editing WG meeting? I don't have permissions to add the "Agenda+" label.

whsieh commented 3 months ago

This seems like a reasonable approach (it's similar to how focus() takes a parameter dictionary, as well as other APIs). Tagging a few more folks from Apple:

@rniwa @megangardner @annevk @marcoscaceres, any thoughts?

rniwa commented 2 months ago

That seems reasonable although it's possible we'd hit some web compatibility issues given we've already shipped this API.