@@ -270,63 +270,6 @@ describe('renderer: optimized mode', () => {
270270 )
271271 } )
272272
273- test ( 'PatchFlags: PatchFlags.STABLE_FRAGMENT with change array item' , async ( ) => {
274- const count = ref ( 0 )
275- const foo : any = [ ]
276- function updateFoo ( ) {
277- for ( let n = 0 ; n < 3 ; n ++ ) {
278- foo [ n ] = n + 1 + '_foo'
279- }
280- }
281- const Comp = {
282- setup ( ) {
283- return ( ) => {
284- // <div>{{ count }}</div>
285- // <div v-for='item in foo'>{{ item }}</div>
286- return (
287- openBlock ( ) ,
288- createElementBlock (
289- Fragment ,
290- null ,
291- [
292- createElementVNode (
293- 'div' ,
294- null ,
295- toDisplayString ( count . value ) ,
296- 1 /* TEXT */ ,
297- ) ,
298- ( openBlock ( ) ,
299- createElementBlock (
300- Fragment ,
301- null ,
302- renderList ( foo , item => {
303- return createElementVNode (
304- 'div' ,
305- null ,
306- toDisplayString ( item ) ,
307- 1 /* TEXT */ ,
308- )
309- } ) ,
310- 64 /* STABLE_FRAGMENT */ ,
311- ) ) ,
312- ] ,
313- 64 /* STABLE_FRAGMENT */ ,
314- )
315- )
316- }
317- } ,
318- }
319-
320- render ( h ( Comp ) , root )
321- expect ( inner ( root ) ) . toBe ( '<div>0</div>' )
322- updateFoo ( )
323- count . value ++
324- await nextTick ( )
325- expect ( inner ( root ) ) . toBe (
326- '<div>1</div><div>1_foo</div><div>2_foo</div><div>3_foo</div>' ,
327- )
328- } )
329-
330273 // A Fragment with `UNKEYED_FRAGMENT` flag will always patch its children,
331274 // so there's no need for tracking dynamicChildren.
332275 test ( 'PatchFlags: PatchFlags.UNKEYED_FRAGMENT' , async ( ) => {
@@ -1351,4 +1294,62 @@ describe('renderer: optimized mode', () => {
13511294 expect ( inner ( root ) ) . toBe ( '<!--v-if-->' )
13521295 expect ( beforeUnmountSpy ) . toHaveBeenCalledTimes ( 1 )
13531296 } )
1297+
1298+ // #12411
1299+ test ( 'handle patch stable fragment with non-reactive v-for source' , async ( ) => {
1300+ const count = ref ( 0 )
1301+ const foo : any = [ ]
1302+ function updateFoo ( ) {
1303+ for ( let n = 0 ; n < 3 ; n ++ ) {
1304+ foo [ n ] = n + 1 + '_foo'
1305+ }
1306+ }
1307+ const Comp = {
1308+ setup ( ) {
1309+ return ( ) => {
1310+ // <div>{{ count }}</div>
1311+ // <div v-for='item in foo'>{{ item }}</div>
1312+ return (
1313+ openBlock ( ) ,
1314+ createElementBlock (
1315+ Fragment ,
1316+ null ,
1317+ [
1318+ createElementVNode (
1319+ 'div' ,
1320+ null ,
1321+ toDisplayString ( count . value ) ,
1322+ PatchFlags . TEXT ,
1323+ ) ,
1324+ ( openBlock ( ) ,
1325+ createElementBlock (
1326+ Fragment ,
1327+ null ,
1328+ renderList ( foo , item => {
1329+ return createElementVNode (
1330+ 'div' ,
1331+ null ,
1332+ toDisplayString ( item ) ,
1333+ PatchFlags . TEXT ,
1334+ )
1335+ } ) ,
1336+ PatchFlags . STABLE_FRAGMENT ,
1337+ ) ) ,
1338+ ] ,
1339+ PatchFlags . STABLE_FRAGMENT ,
1340+ )
1341+ )
1342+ }
1343+ } ,
1344+ }
1345+
1346+ render ( h ( Comp ) , root )
1347+ expect ( inner ( root ) ) . toBe ( '<div>0</div>' )
1348+ updateFoo ( )
1349+ count . value ++
1350+ await nextTick ( )
1351+ expect ( inner ( root ) ) . toBe (
1352+ '<div>1</div><div>1_foo</div><div>2_foo</div><div>3_foo</div>' ,
1353+ )
1354+ } )
13541355} )
0 commit comments