File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
vue-model-api/src/internal Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { useModelsFromJson } from "../useModelsFromJson" ;
2
2
import { computed , isReactive , reactive } from "vue" ;
3
+ import { runGarbageCollection } from "./runGarbageCollection" ;
3
4
4
5
const root = {
5
6
root : {
@@ -159,3 +160,22 @@ test("removing a node is reactive", () => {
159
160
node . remove ( ) ;
160
161
expect ( computedProperty . value ) . toHaveLength ( childCount - 1 ) ;
161
162
} ) ;
163
+
164
+ test ( "garbage collection does not break reactivity" , async ( ) => {
165
+ const rootNode = useRootNode ( ) ;
166
+ // Do not assign the child object to a variable because this would prevent GC from collecting.
167
+ // MODELIX-1041 was caused by child object being garbage collected even when Vue components were subscribed to their properties.
168
+ function getChild ( ) {
169
+ return rootNode . getAllChildren ( ) [ 0 ] ;
170
+ }
171
+ getChild ( ) . setPropertyValue ( "name" , "firstName" ) ;
172
+ const computedChildNames = computed ( ( ) =>
173
+ getChild ( ) . getPropertyValue ( "name" ) ,
174
+ ) ;
175
+ expect ( computedChildNames . value ) . toEqual ( "firstName" ) ;
176
+
177
+ await runGarbageCollection ( ) ;
178
+ getChild ( ) . setPropertyValue ( "name" , "secondName" ) ;
179
+
180
+ expect ( computedChildNames . value ) . toEqual ( "secondName" ) ;
181
+ } ) ;
You can’t perform that action at this time.
0 commit comments