Open Bug 1853878 Opened 8 months ago Updated 8 months ago

Label does not re-dispatch click event from image to target

Categories

(Core :: DOM: Events, defect, P5)

defect

Tracking

()

People

(Reporter: vhilla, Unassigned)

References

(Blocks 1 open bug)

Details

Nightly Version 118.0a1 (2023-08-06) (64-bit), Ubuntu

Steps to reproduce

  1. Open this test case
data:text/html,
<label>
<button onclick="alert('clicked')">btn</button>
<image ismap src="https://upload.wikimedia.org/wikipedia/commons/6/66/SMPTE_Color_Bars.svg">
</label>
  1. Click somewhere within the image

Expected behavior
An alert opens because the label activates the button

Actual behavior
Nothing happens

Reason
HTMLImageElement::GetEventTargetParent sets mMultipleActionsPrevented thereby preventing not only links from submitting (as intended) but also other elements with activation behavior from triggering.

Possible solutions might be

  • Change this to nsEventStatus_eConsumeNoDefault
  • have image or nsImageFrame become the activation target
  • Check in Element::ActivationBehaviorForLinks whether the event target is a link with ismap set to true according to the spec

I can imagine that there are also cases where the a element doesn't become activation target, i.e. link should not be triggered but still is, as nsImageFrame does this regardless of who is activation target. Maybe we should adopt the approach around HTMLInputElement with type=image where the frame stores the last clicked point in a property on the input element, see here.

Severity: S3 → S4
Priority: P3 → P5
You need to log in before you can comment on or make changes to this bug.