Bug 267449
| Summary: | `document.activeElement` for an `onclick` on a `<input type=checkbox>` returns HTMLBodyElement instead of HTMLInputElement | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Karl Dubost <karlcow> |
| Component: | DOM | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED DUPLICATE | ||
| Severity: | Normal | CC: | ap, webkit-bug-importer, webkit |
| Priority: | P2 | Keywords: | BrowserCompat, InRadar |
| Version: | Safari 17 | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| URL: | https://codepen.io/webcompat/pen/zYbKgGd | ||
| See Also: | https://bugs.webkit.org/show_bug.cgi?id=276709 | ||
| Bug Depends on: | 22261 | ||
| Bug Blocks: | 267569 | ||
Karl Dubost
`document.activeElement` for an `onclick` on a `<input type=checkbox>` returns:
* HTMLBodyElement on Safari
* HTMLInputElement on Chrome, Firefox
See https://codepen.io/webcompat/pen/zYbKgGd
<input type="checkbox" id="check" onclick="logme(this)">
<div id="log"></div>
var check = document.querySelector("#check");
var log = document.querySelector("#log");
function logme(element) {
log.textContent += document.activeElement;
}
log.textContent = check;
I will upload a proper test case tomorrow if I can't find a WPT test for it.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/120894916>
Karl Dubost
https://html.spec.whatwg.org/multipage/interaction.html#dom-documentorshadowroot-activeelement-dev
Returns the deepest element in the document through which or to which key events are being routed. This is, roughly speaking, the focused element in the document.
For the purposes of this API, when a child navigable is focused, its container is focused within its parent's active document. For example, if the user moves the focus to a text control in an iframe, the iframe is the element returned by the activeElement API in the iframe's node document.
Similarly, when the focused element is in a different node tree than documentOrShadowRoot, the element returned will be the host that's located in the same node tree as documentOrShadowRoot if documentOrShadowRoot is a shadow-including inclusive ancestor of the focused element, and null if not.
Karl Dubost
This behavior creates a webcompat issue for ceac.state.gov website on Safari.
I should open a bug on https://webcompat.com/
Karl Dubost
MacOS Platform behaves differently than windows with regards to focus on Form Elements. This is a conscious decision to keep.
I'm closing this as a duplicate of Bug 193478
ceac.state.gov was a regression introduced by a modification of the Quirks which was handling this.
*** This bug has been marked as a duplicate of bug 193478 ***
Karl Dubost
*** This bug has been marked as a duplicate of bug 22261 ***