W3C home > Mailing lists > Public > www-style@w3.org > October 2012

Re: Replace document.elementFromPoint() and document.caretPositionFromPoint() by functions named like similar functions returning all elements under the given point

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Mon, 29 Oct 2012 08:06:50 +0100
Message-ID: <CAAWBYDDcBC3Sfnf1YLfZezJJt6jB750mOOWva4oVPKK4nQYsOw@mail.gmail.com>
To: Sebastian Zartner <sebastianzartner@gmail.com>
Cc: www-style list <www-style@w3.org>
On Mon, Oct 29, 2012 at 7:44 AM, Sebastian Zartner
<sebastianzartner@gmail.com> wrote:
> document.elementFromPoint() and document.caretPositionFromPoint() are
> defined to use hit testing to return the uppermost element resp. a range
> related to it at a specific viewport point[1].
> My question is now, what to do when you want to get elements lying under it?
> Therefore I suggest that these functions should be replaced by functions
> returning all elements under that specific point sorted descending by their
> z-order.
> Also their current names don't comply with the naming of similar functions
> like document.getElementsByName().
> So I'd say they should be renamed to document.getElementsFromPoint() and
> document.getCaretPositionsFromPoint().
> For reference: I already mentioned these points in another thread[2][3].
> Sebastian
> [1] http://www.w3.org/TR/cssom-view/#extensions-to-the-document-interface
> [2] http://lists.w3.org/Archives/Public/www-style/2012Oct/0702.html
> [3] http://lists.w3.org/Archives/Public/www-style/2012Oct/0757.html

I agree that we need a plural version of these methods, and argued so
in the recent past.  I have a coworker who worked around the lack by
just repeatedly *removing* the returned element and calling it again
until he hit the <body>, then restoring everything.  This is slow and
hacky and will be incorrect in some cases (if the removal causes
selectors to match differently), and he's just someone within arm's
reach - I'm sure plenty of people have done similar.

I don't think we should change the names.  You're right that they're
not quite consistent with similar methods, but they're not bad enough
to justify the cost of aliasing, I think.

Received on Monday, 29 October 2012 07:07:37 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:23 UTC