Skip to content

Commit dafb0ab

Browse files
authored
script: Stop handling native mousedown and mouseup for disabled elements (servo#38671)
According to spec of [hit-test](https://w3c.github.io/uievents/#hit-test) for native mouse event, mousedown/mouseup should also be excluded when interacting with disabled element, even tho it may be the frontmost of [elementFromPoint](https://drafts.csswg.org/cssom-view/#dom-document-elementfrompoint). Testing: Now it matches the behaviour of other browsers in servo#38670 for disabled element. Also testdriver test: `tests\wpt\tests\html\semantics\disabled-elements\disabled-event-dispatch.tentative.html` has 4 more passing tests. Fixes: Part of servo#38670. Signed-off-by: Euclid Ye <[email protected]>
1 parent 89bd01a commit dafb0ab

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

components/script/dom/document_event_handler.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -530,12 +530,12 @@ impl DocumentEventHandler {
530530

531531
let node = el.upcast::<Node>();
532532
debug!("{:?} on {:?}", event.action, node.debug_str());
533-
// Prevent click event if form control element is disabled.
534-
if let MouseButtonAction::Click = event.action {
535-
// The click event is filtered by the disabled state.
536-
if el.is_actually_disabled() {
537-
return;
538-
}
533+
534+
// https://w3c.github.io/uievents/#hit-test
535+
// Prevent mouse event if element is disabled.
536+
// TODO: also inert.
537+
if el.is_actually_disabled() {
538+
return;
539539
}
540540

541541
let dom_event = DomRoot::upcast::<Event>(MouseEvent::for_platform_mouse_event(

0 commit comments

Comments
 (0)