Skip to content

[cssom-view] MouseEvent.offsetX/offsetY not defined for SVG layout elements #1508

@AmeliaBR

Description

@AmeliaBR

The definition of MouseEvent.offsetX/Y is:

The offsetX[Y] attribute must follow these steps:

  1. If the event’s dispatch flag is set, return the x[y]-coordinate of the position where the event occurred relative to the origin of the padding edge of the target node, ignoring the transforms that apply to the element and its ancestors, and terminate these steps.
  2. Return the value of the event’s pageX[Y] attribute.

Which doesn't give any guidance for what to do when the event target is an SVG layout element, and doesn't have its own padding edge. Firefox seems to use the bounding box of the SVG element (and the local user-space coordinate system). Other browsers seem to use the padding-box of the nearest ancestor <svg> with CSS box layout, and the outside coordinate system for that element (i.e., not including any viewBox scaling). (Firefox does the same when the event target is an <svg> element that has CSS layout boxes.)

For what it's worth: the Firefox behavior is much more useful when working with SVG. But it seems that the cowpath is more heavily-trodden in the other direction.

More generally: reading that definition, I have no idea how "ignoring the transforms" is supposed to be interpreted. Use the local coordinate system or use the document coordinate system?

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