@@ -22,6 +22,8 @@ import EmberDebug from 'ember-debug/main';
2222import setupEmberDebugTest from '../helpers/setup-ember-debug-test' ;
2323import { isInVersionSpecifier } from 'ember-debug/version' ;
2424import { VERSION } from 'ember-debug/ember' ;
25+ import GlimmerComponent from '@glimmer/component' ;
26+ import { tracked } from '@glimmer/tracking' ;
2527
2628let templateOnlyComponent = null ;
2729try {
@@ -373,6 +375,7 @@ module('Ember Debug - View', function (hooks) {
373375 this . route ( 'test-component-in-in-element' ) ;
374376 this . route ( 'wormhole' ) ;
375377 this . route ( 'inputs' ) ;
378+ this . route ( 'component-in-shadow-dom' ) ;
376379 this . route ( 'comments' , { resetNamespace : true } , function ( ) { } ) ;
377380 this . route ( 'posts' , { resetNamespace : true } ) ;
378381 } ,
@@ -499,6 +502,31 @@ module('Ember Debug - View', function (hooks) {
499502 } ) ,
500503 ) ;
501504
505+ this . owner . register (
506+ 'component:shadow-dom' ,
507+ setComponentTemplate (
508+ hbs (
509+ `<div {{did-insert this.setupRoot}} />
510+ {{#if this.shadow}}
511+ {{#in-element this.shadow}}
512+ {{yield}}
513+ {{/in-element}}
514+ {{/if}}
515+ ` ,
516+ {
517+ moduleName : 'my-app/components/shadow-dom.hbs' ,
518+ } ,
519+ ) ,
520+ class extends GlimmerComponent {
521+ @tracked shadow ;
522+ setupRoot = ( element ) => {
523+ this . shadow = element . attachShadow ( { mode : 'open' } ) ;
524+ window . testShadow = this . shadow ;
525+ } ;
526+ } ,
527+ ) ,
528+ ) ;
529+
502530 this . owner . register (
503531 'component:test-foo' ,
504532 setComponentTemplate (
@@ -635,6 +663,13 @@ module('Ember Debug - View', function (hooks) {
635663 } ) ,
636664 ) ;
637665
666+ this . owner . register (
667+ 'template:component-in-shadow-dom' ,
668+ hbs ( '<ShadowDom><TestFoo /></ShadowDom>' , {
669+ moduleName : 'my-app/templates/component-in-shadow-dom.hbs' ,
670+ } ) ,
671+ ) ;
672+
638673 this . owner . register (
639674 'template:comments/index' ,
640675 hbs ( '{{#each this.comments as |comment|}}{{comment}}{{/each}}' , {
@@ -1200,5 +1235,45 @@ module('Ember Debug - View', function (hooks) {
12001235 . dom ( '.ember-inspector-tooltip-detail-instance' , tooltip )
12011236 . hasText ( / e m b e r - w o r m h o l e / ) ;
12021237 } ) ;
1238+
1239+ test ( 'component inside shadow dom' , async function ( assert ) {
1240+ if ( isInVersionSpecifier ( '^5.8.0' , VERSION ) ) {
1241+ assert . expect ( 2 ) ;
1242+ return ;
1243+ }
1244+ await visit ( 'component-in-shadow-dom' ) ;
1245+ await rerender ( ) ;
1246+ await getRenderTree ( ) ;
1247+
1248+ const inShadow = window . testShadow . querySelector ( '.simple-component' ) ;
1249+
1250+ await click ( window . testShadow . host , {
1251+ clientX : inShadow . getBoundingClientRect ( ) . x ,
1252+ clientY : inShadow . getBoundingClientRect ( ) . y ,
1253+ } ) ;
1254+
1255+ assert
1256+ . dom ( '.ember-inspector-tooltip-header' , tooltip )
1257+ . hasText ( '<TestFoo>' ) ;
1258+
1259+ let actual = highlight . getBoundingClientRect ( ) ;
1260+ let expected = inShadow . getBoundingClientRect ( ) ;
1261+
1262+ assert . ok ( isVisible ( tooltip ) , 'tooltip is visible' ) ;
1263+ assert . ok ( isVisible ( highlight ) , 'highlight is visible' ) ;
1264+
1265+ assert . deepEqual ( actual . x , expected . x , 'same x as component' ) ;
1266+ assert . deepEqual ( actual . y , expected . y , 'same y as component' ) ;
1267+ assert . deepEqual ( actual . width , expected . width , 'same width as component' ) ;
1268+ assert . deepEqual (
1269+ actual . height ,
1270+ expected . height ,
1271+ 'same height as component' ,
1272+ ) ;
1273+
1274+ assert
1275+ . dom ( '.ember-inspector-tooltip-detail-instance' , tooltip )
1276+ . hasText ( 'App.TestFooComponent' ) ;
1277+ } ) ;
12031278 } ) ;
12041279} ) ;
0 commit comments