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

Commit ce3e721

Browse files
committed
Reverts #463: ShadowRoots' activeElement no longer returns elements in light DOM.
1 parent 5f12843 commit ce3e721

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

src/ShadowDOM/wrappers/ShadowRoot.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,8 @@
8080

8181
var activeElement = wrap(unwrappedActiveElement);
8282

83-
// If the active element is this ShadowRoot's host, this ShadowRoot
84-
// has no active element.
85-
if (activeElement === this.host) {
86-
return null;
87-
}
88-
89-
// Loop while activeElement is not a shallow descendant of this ShadowRoot
90-
// or this ShadowRoot's host.
91-
while (!this.contains(activeElement) && !this.host.contains(activeElement)) {
83+
// Loop while activeElement is not a shallow child of this ShadowRoot.
84+
while (!this.contains(activeElement)) {
9285
// Iterate until we hit activeElement's containing ShadowRoot (which
9386
// isn't this one) or document.
9487
while (activeElement.parentNode) {

tests/ShadowDOM/html/activeElement.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
r_l.focus();
132132

133133
assert.equal(doc.activeElement, r_l);
134-
assert.equal(r.shadowRoot.activeElement, r_l);
134+
assert.equal(r.shadowRoot.activeElement, null);
135135
assert.equal(r_0.shadowRoot.activeElement, null);
136136
assert.equal(r_0_0.shadowRoot.activeElement, null);
137137
assert.equal(r_0_1.shadowRoot.activeElement, null);
@@ -158,7 +158,7 @@
158158

159159
assert.equal(doc.activeElement, r);
160160
assert.equal(r.shadowRoot.activeElement, r_0_l);
161-
assert.equal(r_0.shadowRoot.activeElement, r_0_l);
161+
assert.equal(r_0.shadowRoot.activeElement, null);
162162
assert.equal(r_0_0.shadowRoot.activeElement, null);
163163
assert.equal(r_0_1.shadowRoot.activeElement, null);
164164
assert.equal(r_1.shadowRoot.activeElement, null);
@@ -185,7 +185,7 @@
185185
assert.equal(doc.activeElement, r);
186186
assert.equal(r.shadowRoot.activeElement, r_0);
187187
assert.equal(r_0.shadowRoot.activeElement, r_0_0_l);
188-
assert.equal(r_0_0.shadowRoot.activeElement, r_0_0_l);
188+
assert.equal(r_0_0.shadowRoot.activeElement, null);
189189
assert.equal(r_0_1.shadowRoot.activeElement, null);
190190
assert.equal(r_1.shadowRoot.activeElement, null);
191191
assert.equal(r_1_0.shadowRoot.activeElement, null);
@@ -212,7 +212,7 @@
212212
assert.equal(r.shadowRoot.activeElement, r_0);
213213
assert.equal(r_0.shadowRoot.activeElement, r_0_1_l);
214214
assert.equal(r_0_0.shadowRoot.activeElement, null);
215-
assert.equal(r_0_1.shadowRoot.activeElement, r_0_1_l);
215+
assert.equal(r_0_1.shadowRoot.activeElement, null);
216216
assert.equal(r_1.shadowRoot.activeElement, null);
217217
assert.equal(r_1_0.shadowRoot.activeElement, null);
218218
assert.equal(r_1_1.shadowRoot.activeElement, null);
@@ -239,7 +239,7 @@
239239
assert.equal(r_0.shadowRoot.activeElement, null);
240240
assert.equal(r_0_0.shadowRoot.activeElement, null);
241241
assert.equal(r_0_1.shadowRoot.activeElement, null);
242-
assert.equal(r_1.shadowRoot.activeElement, r_1_l);
242+
assert.equal(r_1.shadowRoot.activeElement, null);
243243
assert.equal(r_1_0.shadowRoot.activeElement, null);
244244
assert.equal(r_1_1.shadowRoot.activeElement, null);
245245
});
@@ -252,7 +252,7 @@
252252
assert.equal(r_0.shadowRoot.activeElement, null);
253253
assert.equal(r_0_0.shadowRoot.activeElement, null);
254254
assert.equal(r_0_1.shadowRoot.activeElement, null);
255-
assert.equal(r_1.shadowRoot.activeElement, r_1_l);
255+
assert.equal(r_1.shadowRoot.activeElement, null);
256256
assert.equal(r_1_l.shadowRoot.activeElement, r_1_l_0);
257257
assert.equal(r_1_0.shadowRoot.activeElement, null);
258258
assert.equal(r_1_1.shadowRoot.activeElement, null);
@@ -266,7 +266,7 @@
266266
assert.equal(r_0.shadowRoot.activeElement, null);
267267
assert.equal(r_0_0.shadowRoot.activeElement, null);
268268
assert.equal(r_0_1.shadowRoot.activeElement, null);
269-
assert.equal(r_1.shadowRoot.activeElement, r_1_l);
269+
assert.equal(r_1.shadowRoot.activeElement, null);
270270
assert.equal(r_1_l.shadowRoot.activeElement, r_1_l_1);
271271
assert.equal(r_1_0.shadowRoot.activeElement, null);
272272
assert.equal(r_1_1.shadowRoot.activeElement, null);
@@ -294,7 +294,7 @@
294294
assert.equal(r_0_0.shadowRoot.activeElement, null);
295295
assert.equal(r_0_1.shadowRoot.activeElement, null);
296296
assert.equal(r_1.shadowRoot.activeElement, r_1_0_l);
297-
assert.equal(r_1_0.shadowRoot.activeElement, r_1_0_l);
297+
assert.equal(r_1_0.shadowRoot.activeElement, null);
298298
assert.equal(r_1_1.shadowRoot.activeElement, null);
299299
});
300300

@@ -321,7 +321,7 @@
321321
assert.equal(r_0_1.shadowRoot.activeElement, null);
322322
assert.equal(r_1.shadowRoot.activeElement, r_1_1_l);
323323
assert.equal(r_1_0.shadowRoot.activeElement, null);
324-
assert.equal(r_1_1.shadowRoot.activeElement, r_1_1_l);
324+
assert.equal(r_1_1.shadowRoot.activeElement, null);
325325
});
326326
});
327327

0 commit comments

Comments
 (0)