w3c/csswg-drafts

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

Open

#1,156 opened on Apr 1, 2017

View on GitHub
 (1 comment) (0 reactions) (0 assignees)HTML (3,546 stars) (545 forks)batch import
Help Wantedcssom-view-1

Description

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

Contributor guide

[cssom-view] Should Range.getClientRects return an empty sequence when Range is collapsed? · w3c/csswg-drafts#1156 | Good First Issue