[whatwg] Normalization of user selections

On Tue, Jun 28, 2011 at 1:38 PM, Aryeh Gregor <Simetrical+w3c at gmail.com> wrote:
> I've updated the spec to require this:
>
> https://bitbucket.org/ms2ger/dom-range/changeset/b9ca1640aeee
> http://html5.org/specs/dom-range.html#apis-for-the-browsing-context-selection:-the-selection-interface
>
> The boundary points of a selection's range must now always be a Text
> or Element node that descends from a Document. ?Trying to call
> collapse(), extend(), selectAllChildren(), or addRange() in a way that
> would make a boundary point not a Text or Element node will throw
> INVALID_NODE_TYPE_ERR, and trying to make it a node that doesn't
> descend from a Document will throw INVALID_MODIFICATION_ERR. ?I'll add
> more specific constraints on user-created selections later. ?Does
> anyone think this is a bad approach? ?If so, feedback would be
> appreciated.

I eventually reverted this change:

http://dvcs.w3.org/hg/editing/rev/f8c262d61ccc

The reasons are explained in the commit diff.  I couldn't get away
with saying "Selection endpoints can't be Comments" or such unless I
defined what to do to the Selection if one of its Ranges changed, such
as due to a DOM mutation.  That would be a lot more complicated than
just speccing the IE/Gecko behavior, it wouldn't match any browsers,
and it would add only dubious utility.  So now the spec matches
IE/Gecko again -- any Range can be passed to addRange(), and a
reference to that Range will be added to the Selection.

Received on Monday, 24 October 2011 10:48:44 UTC