NEW 238505
Default event target for keyboard events is different in HTML and XHTML documents
https://bugs.webkit.org/show_bug.cgi?id=238505
Summary Default event target for keyboard events is different in HTML and XHTML docum...
Robert Knight
Reported 2022-03-29 08:20:34 PDT
Created attachment 456025 [details] HTML test case When no element is focused in a document, the element to which keyboard events are dispatched is different in XHTML vs HTML documents. Steps to reproduce: 1. Open attached test.html 2. Focus the document, press some keys and note the `target` property of events logged in the browser console 3. Repeat steps 1 and 2 with attached test.xhtml Ideally the keyboard events would be fired at the same element in both HTML and XHTML documents. In Safari and Chrome the keyboard events are fired at the body element for HTML documents and the document element for XHTML documents. In Firefox the keyboard events are fired at the document body for both document types. For XHTML documents that do not have a body element, Firefox fires events at the document element instead, which seems like reasonable fallback behavior. We encountered this issue when investigating a bug in our web app where a keyboard shortcut handler, installed on the document body, didn't work when the code was loaded in an XHTML document.
Attachments
HTML test case (117 bytes, text/html)
2022-03-29 08:20 PDT, Robert Knight
no flags
XHTML test case (193 bytes, application/xhtml+xml)
2022-03-29 08:20 PDT, Robert Knight
no flags
Robert Knight
Comment 1 2022-03-29 08:20:51 PDT
Created attachment 456026 [details] XHTML test case
Robert Knight
Comment 2 2022-03-29 08:21:31 PDT
Radar WebKit Bug Importer
Comment 3 2022-04-05 08:21:18 PDT
Note You need to log in before you can comment on or make changes to this bug.