@@ -1226,6 +1226,92 @@ describe('defineCustomElement', () => {
12261226 expect ( target . innerHTML ) . toBe ( `<span>default</span>` )
12271227 app . unmount ( )
12281228 } )
1229+
1230+ test ( 'toggle nested custom element with shadowRoot: false' , async ( ) => {
1231+ customElements . define (
1232+ 'my-el-child-shadow-false' ,
1233+ defineCustomElement (
1234+ {
1235+ render ( ctx : any ) {
1236+ return h ( 'div' , null , [ renderSlot ( ctx . $slots , 'default' ) ] )
1237+ } ,
1238+ } ,
1239+ { shadowRoot : false } ,
1240+ ) ,
1241+ )
1242+ const ChildWrapper = {
1243+ render ( ) {
1244+ return h ( 'my-el-child-shadow-false' , null , 'child' )
1245+ } ,
1246+ }
1247+
1248+ customElements . define (
1249+ 'my-el-parent-shadow-false' ,
1250+ defineCustomElement (
1251+ {
1252+ props : {
1253+ isShown : { type : Boolean , required : true } ,
1254+ } ,
1255+ render ( ctx : any , _ : any , $props : any ) {
1256+ return $props . isShown
1257+ ? h ( 'div' , { key : 0 } , [ renderSlot ( ctx . $slots , 'default' ) ] )
1258+ : null
1259+ } ,
1260+ } ,
1261+ { shadowRoot : false } ,
1262+ ) ,
1263+ )
1264+ const ParentWrapper = {
1265+ props : {
1266+ isShown : { type : Boolean , required : true } ,
1267+ } ,
1268+ render ( ctx : any , _ : any , $props : any ) {
1269+ return h ( 'my-el-parent-shadow-false' , { isShown : $props . isShown } , [
1270+ renderSlot ( ctx . $slots , 'default' ) ,
1271+ ] )
1272+ } ,
1273+ }
1274+
1275+ const isShown = ref ( true )
1276+ const App = {
1277+ render ( ) {
1278+ return h ( ParentWrapper , { isShown : isShown . value } as any , {
1279+ default : ( ) => [ h ( ChildWrapper ) ] ,
1280+ } )
1281+ } ,
1282+ }
1283+ const container = document . createElement ( 'div' )
1284+ document . body . appendChild ( container )
1285+ const app = createApp ( App )
1286+ app . mount ( container )
1287+ expect ( container . innerHTML ) . toBe (
1288+ `<my-el-parent-shadow-false is-shown="" data-v-app="">` +
1289+ `<div>` +
1290+ `<my-el-child-shadow-false data-v-app="">` +
1291+ `<div>child</div>` +
1292+ `</my-el-child-shadow-false>` +
1293+ `</div>` +
1294+ `</my-el-parent-shadow-false>` ,
1295+ )
1296+
1297+ isShown . value = false
1298+ await nextTick ( )
1299+ expect ( container . innerHTML ) . toBe (
1300+ `<my-el-parent-shadow-false data-v-app=""><!----></my-el-parent-shadow-false>` ,
1301+ )
1302+
1303+ isShown . value = true
1304+ await nextTick ( )
1305+ expect ( container . innerHTML ) . toBe (
1306+ `<my-el-parent-shadow-false data-v-app="" is-shown="">` +
1307+ `<div>` +
1308+ `<my-el-child-shadow-false data-v-app="">` +
1309+ `<div>child</div>` +
1310+ `</my-el-child-shadow-false>` +
1311+ `</div>` +
1312+ `</my-el-parent-shadow-false>` ,
1313+ )
1314+ } )
12291315 } )
12301316
12311317 describe ( 'helpers' , ( ) => {
0 commit comments