Skip to content

Commit 47ee2ca

Browse files
committed
Use local references to wrapper functions; add test element tree to native shadow tests; reorder test elements.
1 parent e848af8 commit 47ee2ca

4 files changed

Lines changed: 80 additions & 73 deletions

File tree

‎src/lib/dom-api-shadow.html‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@
6060

6161
activeElement: {
6262
get: function() {
63-
var node = Polymer.DomApi.wrap(this.node);
63+
var node = DomApi.wrap(this.node);
6464
var activeElement = node.activeElement;
65+
// Prevents `activeElement` from returning elements outside of the
66+
// ShadowRoot, even if they would become descendants of the ShadowRoot
67+
// in the composed tree. See w3c/webcomponents#358.
6568
return node.contains(activeElement) ? activeElement : null;
6669
},
6770
configurable: true

‎src/lib/dom-api-shady.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,10 +446,10 @@
446446
// This node is either the document or a shady root of which the active
447447
// element is a (composed) descendant of its host; iterate upwards to
448448
// find the active element's most shallow host within it.
449-
var activeRoot = Polymer.dom(active).getOwnerRoot();
449+
var activeRoot = dom(active).getOwnerRoot();
450450
while (activeRoot && activeRoot !== this.node) {
451451
active = activeRoot.host;
452-
activeRoot = Polymer.dom(active).getOwnerRoot();
452+
activeRoot = dom(active).getOwnerRoot();
453453
}
454454
if (this.node === document) {
455455
// This node is the document, so activeRoot should be null.

‎test/unit/polymer-dom-elements.html‎

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -359,36 +359,67 @@
359359
</dom-module>
360360

361361

362-
<dom-module id="x-shadow-host-root">
362+
<dom-module id="x-shadow-host-root-0-0">
363363
<template>
364364
<content></content>
365+
</template>
366+
<script>
367+
Polymer({
368+
is: 'x-shadow-host-root-0-0',
369+
hostAttributes: {
370+
tabindex: '-1'
371+
}
372+
});
373+
</script>
374+
</dom-module>
375+
376+
<dom-module id="x-shadow-host-root-0-0-light-0">
377+
<script>
378+
Polymer({
379+
is: 'x-shadow-host-root-0-0-light-0',
380+
hostAttributes: {
381+
tabindex: '-1'
382+
}
383+
});
384+
</script>
385+
</dom-module>
386+
387+
<dom-module id="x-shadow-host-root-0-0-light">
388+
<template>
365389
<div>
366390
<div>
367-
<x-shadow-host-root-0>
368-
<x-shadow-host-root-0-light></x-shadow-host-root-0-light>
369-
</x-shadow-host-root-0>
391+
<x-shadow-host-root-0-0-light-0></x-shadow-host-root-0-0-light-0>
370392
</div>
371393
</div>
372-
<div>
373-
<x-shadow-host-root-1>
374-
<x-shadow-host-root-1-light></x-shadow-host-root-1-light>
375-
</x-shadow-host-root-1>
376-
</div>
377394
</template>
378395
<script>
379396
Polymer({
380-
is: 'x-shadow-host-root',
397+
is: 'x-shadow-host-root-0-0-light',
381398
hostAttributes: {
382399
tabindex: '-1'
383400
}
384401
});
385402
</script>
386403
</dom-module>
387404

388-
<dom-module id="x-shadow-host-root-light">
405+
<dom-module id="x-shadow-host-root-0-1">
406+
<template>
407+
<content></content>
408+
</template>
389409
<script>
390410
Polymer({
391-
is: 'x-shadow-host-root-light',
411+
is: 'x-shadow-host-root-0-1',
412+
hostAttributes: {
413+
tabindex: '-1'
414+
}
415+
});
416+
</script>
417+
</dom-module>
418+
419+
<dom-module id="x-shadow-host-root-0-1-light">
420+
<script>
421+
Polymer({
422+
is: 'x-shadow-host-root-0-1-light',
392423
hostAttributes: {
393424
tabindex: '-1'
394425
}
@@ -429,67 +460,49 @@
429460
</script>
430461
</dom-module>
431462

432-
<dom-module id="x-shadow-host-root-0-0">
463+
<dom-module id="x-shadow-host-root-1-0">
433464
<template>
434465
<content></content>
435466
</template>
436467
<script>
437468
Polymer({
438-
is: 'x-shadow-host-root-0-0',
439-
hostAttributes: {
440-
tabindex: '-1'
441-
}
442-
});
443-
</script>
444-
</dom-module>
445-
446-
<dom-module id="x-shadow-host-root-0-0-light">
447-
<template>
448-
<div>
449-
<div>
450-
<x-shadow-host-root-0-0-light-0></x-shadow-host-root-0-0-light-0>
451-
</div>
452-
</div>
453-
</template>
454-
<script>
455-
Polymer({
456-
is: 'x-shadow-host-root-0-0-light',
469+
is: 'x-shadow-host-root-1-0',
457470
hostAttributes: {
458471
tabindex: '-1'
459472
}
460473
});
461474
</script>
462475
</dom-module>
463476

464-
<dom-module id="x-shadow-host-root-0-0-light-0">
477+
<dom-module id="x-shadow-host-root-1-0-light">
465478
<script>
466479
Polymer({
467-
is: 'x-shadow-host-root-0-0-light-0',
480+
is: 'x-shadow-host-root-1-0-light',
468481
hostAttributes: {
469482
tabindex: '-1'
470483
}
471484
});
472485
</script>
473486
</dom-module>
474487

475-
<dom-module id="x-shadow-host-root-0-1">
488+
<dom-module id="x-shadow-host-root-1-1">
476489
<template>
477490
<content></content>
478491
</template>
479492
<script>
480493
Polymer({
481-
is: 'x-shadow-host-root-0-1',
494+
is: 'x-shadow-host-root-1-1',
482495
hostAttributes: {
483496
tabindex: '-1'
484497
}
485498
});
486499
</script>
487500
</dom-module>
488501

489-
<dom-module id="x-shadow-host-root-0-1-light">
502+
<dom-module id="x-shadow-host-root-1-1-light">
490503
<script>
491504
Polymer({
492-
is: 'x-shadow-host-root-0-1-light',
505+
is: 'x-shadow-host-root-1-1-light',
493506
hostAttributes: {
494507
tabindex: '-1'
495508
}
@@ -525,20 +538,6 @@
525538
</script>
526539
</dom-module>
527540

528-
<dom-module id="x-shadow-host-root-1-light">
529-
<template>
530-
<x-shadow-host-root-1-light-0></x-shadow-host-root-1-light-0>
531-
</template>
532-
<script>
533-
Polymer({
534-
is: 'x-shadow-host-root-1-light',
535-
hostAttributes: {
536-
tabindex: '-1'
537-
}
538-
});
539-
</script>
540-
</dom-module>
541-
542541
<dom-module id="x-shadow-host-root-1-light-0">
543542
<script>
544543
Polymer({
@@ -550,49 +549,50 @@
550549
</script>
551550
</dom-module>
552551

553-
<dom-module id="x-shadow-host-root-1-0">
552+
<dom-module id="x-shadow-host-root-1-light">
554553
<template>
555-
<content></content>
554+
<x-shadow-host-root-1-light-0></x-shadow-host-root-1-light-0>
556555
</template>
557556
<script>
558557
Polymer({
559-
is: 'x-shadow-host-root-1-0',
560-
hostAttributes: {
561-
tabindex: '-1'
562-
}
563-
});
564-
</script>
565-
</dom-module>
566-
567-
<dom-module id="x-shadow-host-root-1-0-light">
568-
<script>
569-
Polymer({
570-
is: 'x-shadow-host-root-1-0-light',
558+
is: 'x-shadow-host-root-1-light',
571559
hostAttributes: {
572560
tabindex: '-1'
573561
}
574562
});
575563
</script>
576564
</dom-module>
577565

578-
<dom-module id="x-shadow-host-root-1-1">
566+
<dom-module id="x-shadow-host-root">
579567
<template>
580568
<content></content>
569+
<div>
570+
<div>
571+
<x-shadow-host-root-0>
572+
<x-shadow-host-root-0-light></x-shadow-host-root-0-light>
573+
</x-shadow-host-root-0>
574+
</div>
575+
</div>
576+
<div>
577+
<x-shadow-host-root-1>
578+
<x-shadow-host-root-1-light></x-shadow-host-root-1-light>
579+
</x-shadow-host-root-1>
580+
</div>
581581
</template>
582582
<script>
583583
Polymer({
584-
is: 'x-shadow-host-root-1-1',
584+
is: 'x-shadow-host-root',
585585
hostAttributes: {
586586
tabindex: '-1'
587587
}
588588
});
589589
</script>
590590
</dom-module>
591591

592-
<dom-module id="x-shadow-host-root-1-1-light">
592+
<dom-module id="x-shadow-host-root-light">
593593
<script>
594594
Polymer({
595-
is: 'x-shadow-host-root-1-1-light',
595+
is: 'x-shadow-host-root-light',
596596
hostAttributes: {
597597
tabindex: '-1'
598598
}

‎test/unit/polymer-dom-native-shadow.html‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656

5757
<x-wrapped></x-wrapped>
5858

59+
<x-shadow-host-root>
60+
<x-shadow-host-root-light></x-shadow-host-root-light>
61+
</x-shadow-host-root>
62+
5963
<script src="polymer-dom.js"></script>
6064

6165
</body>

0 commit comments

Comments
 (0)