User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:34.0) Gecko/20100101 Firefox/34.0 Build ID: 20141125180439 Steps to reproduce: 1. created a ShadowDOM structure (see attached test case) 2. focused element within a ShadowRoot 3. verified focused element with document.activeElement Live test case: http://medialize.github.io/ally.js/tests/browser-bugs/gecko-shadow-dom-active-element.html Actual results: When focusing a shadowed element (i.e. an element within a ShadowRoot) that element is exposed to document.activeElement - i.e. document.activeElement leaks the content of the ShadowRoot. Also there is no ShadowRoot.activeElement - which is necessary to actually get to the focused element from the adjusted target (i.e. the ShadowHost). Also reproducible in Firefox Nightly 37.0a1 (2015-01-04). Expected results: document.activeElement should point to the (top most) ShadowHost containing the focused element. ShadowRoot.activeElement should point to the focused element in that ShadowRoot (as document.activeElement does for the document).
Gabor, do you know what's going on here? (after bug 777674 you are now the person I associate with shadow dom implementation stuff... :-) )
(In reply to :Gijs Kruitbosch from comment #2) > Gabor, do you know what's going on here? (after bug 777674 you are now the > person I associate with shadow dom implementation stuff... :-) ) I think you would have better luck with William or Olli, but I'm happy if you keep me in the loop :) I think Olli worked on making the focusing stuff work, so I'm passing the needInfo flag to him. He might know something off the top of his head, otherwise I can dive into this.
I thought we had a bug open for this, but maybe not.
It may also be of interest that if document.activeElement is not cleaned up (reset to document.body) when he ShadowRoot that element belonged to is removed. In that case document.activeElement.blur() does nothing and the only way out of that hole is to first focus another element in the document itself, before running document.activeElement.blur().