Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTMLElement.blur() should cancel all the focus in sub tree? #6999

Open
mantou132 opened this issue Aug 20, 2021 · 1 comment
Open

HTMLElement.blur() should cancel all the focus in sub tree? #6999

mantou132 opened this issue Aug 20, 2021 · 1 comment
Labels
interop Implementations are not interoperable with each other topic: focus

Comments

@mantou132
Copy link

Example:

document.body.innerHTML = `
  <my-ele>
    <div tabindex=1>focusable</div>
  </my-ele>
`
document.querySelector('div').focus();
document.querySelector('my-ele').blur();
document.body.append(`current active element: ${document.activeElement.tagName}`);

Firefox: current active element: DIV
Chrome: current active element: BODY
Safari: current active element: BODY

@mantou132 mantou132 changed the title customelement.blur() should cancel all the focus in ShadowDOM? HTMLElement.blur() should cancel all the focus in sub tree? Aug 20, 2021
@annevk annevk transferred this issue from whatwg/dom Aug 30, 2021
@domenic
Copy link
Member

domenic commented Aug 30, 2021

blur() runs the unfocusing steps on the element. That algorithm can be a bit confusing, but to me it looks like the spec matches Firefox's behavior right now: old chain consists of the div and the document, so step 4 returns without doing anything.

I tried looking at Chromium code but it's pretty confusing and not very similar to the spec, so it's not clear what the right fix would be here.

@domenic domenic added the interop Implementations are not interoperable with each other label Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interop Implementations are not interoperable with each other topic: focus
Development

No branches or pull requests

3 participants