File tree 2 files changed +41
-0
lines changed
2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -1690,6 +1690,46 @@ describe('Suspense', () => {
1690
1690
expect ( serializeInner ( root ) ) . toBe ( `<div>sync</div>` )
1691
1691
} )
1692
1692
1693
+ // #6416 follow up
1694
+ test ( 'Suspense patched during HOC async component re-mount' , async ( ) => {
1695
+ const key = ref ( 'k' )
1696
+ const data = ref ( 'data' )
1697
+
1698
+ const Async = defineAsyncComponent ( {
1699
+ render ( ) {
1700
+ return h ( 'div' , 'async' )
1701
+ }
1702
+ } )
1703
+
1704
+ const Comp = {
1705
+ render ( ) {
1706
+ return h ( Async , { key : key . value } )
1707
+ }
1708
+ }
1709
+
1710
+ const root = nodeOps . createElement ( 'div' )
1711
+ const App = {
1712
+ render ( ) {
1713
+ return h ( Suspense , null , {
1714
+ default : h ( Comp , { data : data . value } )
1715
+ } )
1716
+ }
1717
+ }
1718
+ render ( h ( App ) , root )
1719
+ expect ( serializeInner ( root ) ) . toBe ( `<!---->` )
1720
+
1721
+ await Promise . all ( deps )
1722
+
1723
+ // async mounted, but key change causing a new async comp to be loaded
1724
+ key . value = 'k1'
1725
+ await nextTick ( )
1726
+
1727
+ // patch the Suspense
1728
+ // should not throw error due to Suspense vnode.el being null
1729
+ data . value = 'data2'
1730
+ await Promise . all ( deps )
1731
+ } )
1732
+
1693
1733
describe ( 'warnings' , ( ) => {
1694
1734
// base function to check if a combination of slots warns or not
1695
1735
function baseCheckWarn (
Original file line number Diff line number Diff line change @@ -428,6 +428,7 @@ export function updateHOCHostEl(
428
428
{ vnode, parent } : ComponentInternalInstance ,
429
429
el : typeof vnode . el // HostNode
430
430
) {
431
+ if ( ! el ) return
431
432
while ( parent ) {
432
433
const root = parent . subTree
433
434
if ( root . suspense && root . suspense . activeBranch === vnode ) {
You can’t perform that action at this time.
0 commit comments