+62
-2
lines changedFilter options
+62
-2
lines changed Original file line number Diff line number Diff line change
@@ -20,7 +20,9 @@ import {
20
20
onBeforeUnmount,
21
21
createTextVNode,
22
22
SetupContext,
23
-
createApp
23
+
createApp,
24
+
FunctionalComponent,
25
+
renderList
24
26
} from '@vue/runtime-test'
25
27
import { PatchFlags, SlotFlags } from '@vue/shared'
26
28
import { SuspenseImpl } from '../src/components/Suspense'
@@ -821,4 +823,62 @@ describe('renderer: optimized mode', () => {
821
823
await nextTick()
822
824
expect(inner(root)).toBe('<div><div>true</div></div>')
823
825
})
826
+
827
+
// #3881
828
+
// root cause: fragment inside a compiled slot passed to component which
829
+
// programmatically invokes the slot. The entire slot should de-opt but
830
+
// the fragment was incorretly put in optimized mode which causes it to skip
831
+
// updates for its inner components.
832
+
test('fragments inside programmatically invoked compiled slot should de-opt properly', async () => {
833
+
const Parent: FunctionalComponent = (_, { slots }) => slots.default!()
834
+
const Dummy = () => 'dummy'
835
+
836
+
const toggle = ref(true)
837
+
const force = ref(0)
838
+
839
+
const app = createApp({
840
+
render() {
841
+
if (!toggle.value) {
842
+
return null
843
+
}
844
+
return h(
845
+
Parent,
846
+
{ n: force.value },
847
+
{
848
+
default: withCtx(
849
+
() => [
850
+
createVNode('ul', null, [
851
+
(openBlock(),
852
+
createBlock(
853
+
Fragment,
854
+
null,
855
+
renderList(1, item => {
856
+
return createVNode('li', null, [createVNode(Dummy)])
857
+
}),
858
+
64 /* STABLE_FRAGMENT */
859
+
))
860
+
])
861
+
],
862
+
undefined,
863
+
true
864
+
),
865
+
_: 1 /* STABLE */
866
+
}
867
+
)
868
+
}
869
+
})
870
+
871
+
app.mount(root)
872
+
873
+
// force a patch
874
+
force.value++
875
+
await nextTick()
876
+
expect(inner(root)).toBe(`<ul><li>dummy</li></ul>`)
877
+
878
+
// unmount
879
+
toggle.value = false
880
+
await nextTick()
881
+
// should successfully unmount without error
882
+
expect(inner(root)).toBe(`<!---->`)
883
+
})
824
884
})
Original file line number Diff line number Diff line change
@@ -1170,7 +1170,7 @@ function baseCreateRenderer(
1170
1170
const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''))!
1171
1171
1172
1172
let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2
1173
-
if (patchFlag > 0) {
1173
+
if (dynamicChildren) {
1174
1174
optimized = true
1175
1175
}
1176
1176
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4