Fix for IE11 bug where document.activeElement sometimes returns a null-prototyped object.

This commit is contained in:
Russell Bicknell
2015-12-02 18:29:00 -08:00
parent a67cf37390
commit 484f2dd6fc
2 changed files with 8 additions and 2 deletions

View File

@@ -52,7 +52,10 @@
defineWrapGetter(Document, 'head');
defineGetter(Document, 'activeElement', function() {
var activeElement = wrap(unwrap(this).activeElement);
var unwrappedActiveElement = unwrap(this).activeElement;
if (!unwrappedActiveElement || !unwrappedActiveElement.nodeType) return null;
var activeElement = wrap(unwrappedActiveElement);
// Loop while activeElement is not a shallow child of this document.
while (!this.contains(activeElement)) {

View File

@@ -75,7 +75,10 @@
},
get activeElement() {
var activeElement = wrap(unwrap(this).ownerDocument.activeElement);
var unwrappedActiveElement = unwrap(this).ownerDocument.activeElement;
if (!unwrappedActiveElement || !unwrappedActiveElement.nodeType) return null;
var activeElement = wrap(unwrappedActiveElement);
// Loop while activeElement is not a shallow child of this ShadowRoot.
while (!this.contains(activeElement)) {