Re: [Selection] Should selection.getRangeAt return a clone or a reference?

On Sun, Jan 25, 2015 at 1:31 AM, Mats Palmgren <mats@mozilla.com> wrote:
> Gecko knows if a Range is part of a Selection or not.

Authors don't, I don't think.  Of course, we could expose this info to
authors if we wanted, so that's not a big problem.

> True, I'm just saying that I don't see any practical problems in
> implementing live ranges to manipulate the Selection if we want to.

I don't think there are any implementation problems, I just think it's
an API that's confusing to authors relative to the alternative
(returning copies).  And it's probably easier for the UAs that return
references to switch to returning copies than the reverse, so it
increases the chance of convergence in the near term.  Also, if
mutating the range throws, it will break author code; but if it fails
silently, it creates a "what on earth is going wrong?!" head-banging
scenario for authors.  And anything authors can do with a reference,
they can do with a copy just as well, by mutating the copy,
.removeRange(), .addRange().  So I think returning a copy makes much
more sense.

Received on Sunday, 25 January 2015 12:03:20 UTC