Re: [CSSOM] getClientRects should work on collapsed ranges in elements

On Fri, Aug 13, 2010 at 4:55 AM, Robert O'Callahan <robert@ocallahan.org>wrote:

> Ojan suggested that range.getClientsRects on a collapsed range should give
> you the same result as if you had inserted an empty text node at that
> position in the DOM and called getClientRects on that text node.
>
> I have two weak concerns about that approach. If inserting an empty text
> node into the DOM can cause significant changes in layout in some
> situations, it could be very difficult to implement ... but right now I
> can't think of any such cases. Also, there are situations where inserting an
> empty text node into the DOM does not create any CSS box for the text node,
> so getClientRects will return an empty list; applications would have to deal
> with that possibility.
>
> Apart from those concerns, I think Ojan's suggestion is fine.
>

Those are totally valid concerns. Ideally we could spec this so that it
would also work in the situations where inserting an empty text node doesn't
create a CSS box, which is what IE does, but I'm not sure how. Even without
that, I think this would be an improvement. It's incrementally closer to
what IE does and, in my opinion, gets closer to meeting the use-case for
this API.

Ojan

Received on Wednesday, 18 August 2010 21:08:25 UTC