@@ -270,6 +270,12 @@ const getBootstrapData = (options?: {
270270 menu : {
271271 breadcrumb : { items : [ { text : "Nested" } ] } ,
272272 } ,
273+ context : [
274+ {
275+ name : "mountCount" ,
276+ value : 0 ,
277+ } ,
278+ ] ,
273279 bricks : [
274280 {
275281 brick : "div" ,
@@ -304,6 +310,18 @@ const getBootstrapData = (options?: {
304310 textContent : "Sub 2" ,
305311 } ,
306312 } ,
313+ {
314+ brick : "output" ,
315+ properties : {
316+ textContent : "<%= CTX.mountCount %>" ,
317+ } ,
318+ lifeCycle : {
319+ onMount : {
320+ action : "context.replace" ,
321+ args : [ "mountCount" , "<%= CTX.mountCount + 1 %>" ] ,
322+ } ,
323+ } ,
324+ } ,
307325 {
308326 brick : "div" ,
309327 children : [
@@ -1109,6 +1127,9 @@ describe("Runtime", () => {
11091127 <p>
11101128 Sub 2
11111129 </p>
1130+ <output>
1131+ 1
1132+ </output>
11121133 <div>
11131134 <div
11141135 slot="content"
@@ -1136,6 +1157,9 @@ describe("Runtime", () => {
11361157 <p>
11371158 Sub 2
11381159 </p>
1160+ <output>
1161+ 1
1162+ </output>
11391163 <div>
11401164 <div
11411165 slot="content"
@@ -1167,6 +1191,9 @@ describe("Runtime", () => {
11671191 <p>
11681192 Sub 2
11691193 </p>
1194+ <output>
1195+ 1
1196+ </output>
11701197 <div>
11711198 <div
11721199 slot="content"
@@ -1187,7 +1214,37 @@ describe("Runtime", () => {
11871214 breadcrumb : [ { text : "Nested" } , { text : "2" } , { text : "Y" } ] ,
11881215 } ) ;
11891216
1190- ( window as any ) . debug = true ;
1217+ // Go back to the middle-parent route, won't re-render the middle-parent route.
1218+ // `output` is 1, left unchanged.
1219+ getHistory ( ) . push ( "/app-a/sub-routes-nested/2" ) ;
1220+ await ( global as any ) . flushPromises ( ) ;
1221+ expect ( getRuntime ( ) . getNavConfig ( ) ) . toEqual ( {
1222+ breadcrumb : [ { text : "Nested" } , { text : "2" } ] ,
1223+ } ) ;
1224+ expect ( document . body . children ) . toMatchInlineSnapshot ( `
1225+ HTMLCollection [
1226+ <div
1227+ id="main-mount-point"
1228+ >
1229+ <div>
1230+ <p>
1231+ Sub 2
1232+ </p>
1233+ <output>
1234+ 1
1235+ </output>
1236+ <div>
1237+ <div
1238+ slot="content"
1239+ />
1240+ </div>
1241+ </div>
1242+ </div>,
1243+ <div
1244+ id="portal-mount-point"
1245+ />,
1246+ ]
1247+ ` ) ;
11911248
11921249 getHistory ( ) . push ( "/app-a/sub-routes-nested/1" ) ;
11931250 await ( global as any ) . flushPromises ( ) ;
@@ -1210,6 +1267,38 @@ describe("Runtime", () => {
12101267 expect ( getRuntime ( ) . getNavConfig ( ) ) . toEqual ( {
12111268 breadcrumb : [ { text : "Nested" } , { text : "1" } ] ,
12121269 } ) ;
1270+
1271+ // Go to the sibling route, will re-render the sibling route.
1272+ // `output` is 2, increased.
1273+ getHistory ( ) . push ( "/app-a/sub-routes-nested/2" ) ;
1274+ await ( global as any ) . flushPromises ( ) ;
1275+ expect ( getRuntime ( ) . getNavConfig ( ) ) . toEqual ( {
1276+ breadcrumb : [ { text : "Nested" } , { text : "2" } ] ,
1277+ } ) ;
1278+ expect ( document . body . children ) . toMatchInlineSnapshot ( `
1279+ HTMLCollection [
1280+ <div
1281+ id="main-mount-point"
1282+ >
1283+ <div>
1284+ <p>
1285+ Sub 2
1286+ </p>
1287+ <output>
1288+ 2
1289+ </output>
1290+ <div>
1291+ <div
1292+ slot="content"
1293+ />
1294+ </div>
1295+ </div>
1296+ </div>,
1297+ <div
1298+ id="portal-mount-point"
1299+ />,
1300+ ]
1301+ ` ) ;
12131302 } , 1e6 ) ;
12141303
12151304 test ( "parallel incremental sub-routes rendering" , async ( ) => {
0 commit comments