File tree Expand file tree Collapse file tree
packages/runtime-vapor/__tests__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -931,6 +931,30 @@ describe('defineVaporCustomElement', () => {
931931 )
932932 } )
933933
934+ test ( 'should resolve correct parent when element is slotted in shadow DOM' , async ( ) => {
935+ const GrandParent = defineVaporCustomElement ( {
936+ setup ( ) {
937+ provide ( 'foo' , ref ( 'GrandParent' ) )
938+ const n0 = createPlainElement ( 'my-parent-in-shadow' , null , {
939+ default : ( ) => template ( '<slot></slot>' ) ( ) ,
940+ } )
941+ return n0
942+ } ,
943+ } )
944+ const Parent = defineVaporCustomElement ( {
945+ setup ( ) {
946+ provide ( 'foo' , ref ( 'Parent' ) )
947+ return template ( '<slot></slot>' ) ( )
948+ } ,
949+ } )
950+ customElements . define ( 'my-grand-parent' , GrandParent )
951+ customElements . define ( 'my-parent-in-shadow' , Parent )
952+ container . innerHTML = `<my-grand-parent><my-consumer></my-consumer></my-grand-parent>`
953+ const grandParent = container . childNodes [ 0 ] as VaporElement ,
954+ consumer = grandParent . firstElementChild as VaporElement
955+ expect ( consumer . shadowRoot ! . textContent ) . toBe ( 'Parent' )
956+ } )
957+
934958 test ( 'inherited from app context within nested elements' , async ( ) => {
935959 const outerValues : ( string | undefined ) [ ] = [ ]
936960 const innerValues : ( string | undefined ) [ ] = [ ]
You can’t perform that action at this time.
0 commit comments