Skip to content
This repository was archived by the owner on Sep 20, 2019. It is now read-only.

Commit 484f2dd

Browse files
committed
Fix for IE11 bug where document.activeElement sometimes returns a null-prototyped object.
1 parent a67cf37 commit 484f2dd

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/ShadowDOM/wrappers/Document.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@
5252
defineWrapGetter(Document, 'head');
5353

5454
defineGetter(Document, 'activeElement', function() {
55-
var activeElement = wrap(unwrap(this).activeElement);
55+
var unwrappedActiveElement = unwrap(this).activeElement;
56+
if (!unwrappedActiveElement || !unwrappedActiveElement.nodeType) return null;
57+
58+
var activeElement = wrap(unwrappedActiveElement);
5659

5760
// Loop while activeElement is not a shallow child of this document.
5861
while (!this.contains(activeElement)) {

src/ShadowDOM/wrappers/ShadowRoot.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@
7575
},
7676

7777
get activeElement() {
78-
var activeElement = wrap(unwrap(this).ownerDocument.activeElement);
78+
var unwrappedActiveElement = unwrap(this).ownerDocument.activeElement;
79+
if (!unwrappedActiveElement || !unwrappedActiveElement.nodeType) return null;
80+
81+
var activeElement = wrap(unwrappedActiveElement);
7982

8083
// Loop while activeElement is not a shallow child of this ShadowRoot.
8184
while (!this.contains(activeElement)) {

0 commit comments

Comments
 (0)