8000 [cssom-view] Behavior of MouseEvent.offsetX/Y with inline elements is inconsistent across browsers · Issue #5659 · w3c/csswg-drafts · GitHub
[go: up one dir, main page]

Skip to content

[cssom-view] Behavior of MouseEvent.offsetX/Y with inline elements is inconsistent across browsers #5659

@noamr

Description

@noamr

See https://drafts.csswg.org/cssom-view/#dom-mouseevent-offsetx
According to the spec, offsetX/offsetY of the MouseEvent should correspond to the target element's padding edge.
However, only Gecko conforms to that when it comes to inline elements.

This makes it so that getting the offsetX for e.g. a elements requires an additional computation, and only on certain browsers, and basically makes offsetX/Y unusable for inline elements.

In the Chromium bug https://bugs.chromium.org/p/chromium/issues/detail?id=1054515#c21 it is stated that web compatibility would be an issue if they decide to change this.

Currently the only way to compute offsetX/Y in a cross-browser way is to use potentially costly measurements such as getClientRects and subtracting them from the event's clientX/clientY.
Some websites do this to avoid the cross-browser complexities.

I suggest one of the following:

  • Fix the issue in Blink/WebKit to match the spec (I am in favor in this, but not too familiar with the web-compat implication)
  • Change the spec and Fix Gecko, maybe create an alternate API to retrieve the offsetX/Y for an inline-element

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

      0