Skip to content

[cssom-view] Should Range.getClientRects return an empty sequence when Range is collapsed? #1156

Open
@galmacky

Description

@galmacky

https://drafts.csswg.org/cssom-view/#extensions-to-the-range-interface

In the above spec, it is somewhat unclear whether Range.getClientRects() should return an empty sequence, or return a sequence containing a ClientRect that has either width of 0 or height of 0, if the Range is collapsed. At a glance, it looks like an empty sequence must be returned only if the range is not in the document, but there was confusion among people in the discussion (linked at the end of this posting), so hereby requesting clarification, preferably in the form of test. FYI, a draft version of this test is uploaded at https://jsbin.com/jodiharuni/edit?html,output [courtesy of foolip@chromium.org].

Also behavior differs from browser to browser, when observed on DIV contenteditable.

Chrome/Safari
a) DIV is empty: it returns a sequence of ClientRect that has a width of 0.
b) DIV is \n\n: it returns an empty sequence
c) Start with \n\n, type 'a', and delete 'a': it returns a sequence of ClientRect that has a width of the container.

FireFox
a) DIV is empty: not focusable, therefore not testable
b) DIV is \n\n: not focusable, therefore not testable
c) Start with 'a', and delete 'a': it returns an empty sequence

Edge / IE11
a) DIV is empty: it returns a sequence of ClientRect that has a width of 0.
b) DIV is \n\n: it returns a sequence of ClientRect that has a width of 0.
c) Start with \n\n, type 'a', and delete 'a': it returns a sequence of ClientRect that has a width of 0.

For more discussion around this: https://crbug.com/698752

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions