From 71232f6f641d74bcf909679b09287f454806f72f Mon Sep 17 00:00:00 2001 From: cinereal Date: Sun, 18 Oct 2026 11:50:26 +0200 Subject: [PATCH 1/3] perf(vue): keep the state of a form shallow `JsonForms` returns `schemaToUse`, `uischemaToUse` and the `jsonforms` object from `data()`, thus Vue makes a deep proxy for the schema, the UI schema, the renderers, the cells and `ajv`. Testers and the scope resolution read the schema many times for each control, thus a large form makes and reads many thousands of proxies. A profile of a 160-field form gave 45% of the samples to `isEmpty` and 15% to the proxy `ownKeys` trap. The mount time of that form goes from 1790 ms to 1000 ms. `shallowRef` and `shallowReactive` keep this state shallow. Vue keeps a `shallowReactive` object as it is when it makes the object of `data()` reactive, and the reactive traps read and write through a `shallowRef`, thus the component keeps its usual behavior. A reducer replaces `core` for each change, thus shallow tracking is sufficient for the renderers, which read the state through computed props. The state holds the value of a prop without `markRaw`, thus JSON Forms writes no flag on the object of the application, and a deep watcher of the application still runs. `toRaw` gets the `ajv` instance itself, because Ajv cannot compile a schema through a proxy of itself. The `data` watcher compares the raw objects, because a parent that passes back the current form data can give a proxy of that data. Without this, the form generates a new schema for its own data. An application that keeps these values out of deep reactive state no longer needs `markRaw` for them. `AdditionalProperties` of `@jsonforms/vue-vuetify`, the example application and the tests no longer apply it. `MIGRATION.md` gets an entry. The form data that a renderer gets is no longer a proxy, thus a change of the data needs `handleChange`. Assisted-by: Claude:claude-fable-5-1 Claude-Session: https://claude.ai/code/session_016KGK8Duuq2tHJMm2mVcdFu --- MIGRATION.md | 15 ++ packages/vue-vuetify/dev/validate/index.ts | 4 +- .../vue-vuetify/dev/views/ExampleView.vue | 7 +- .../components/AdditionalProperties.vue | 7 +- .../AdditionalPropertiesAjv.spec.ts | 3 +- packages/vue-vuetify/tests/unit/util/util.ts | 3 +- packages/vue/src/components/JsonForms.vue | 41 +++- packages/vue/tests/unit/JsonForms.spec.ts | 202 +++++++++++++++++- 8 files changed, 254 insertions(+), 28 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index 8020822aea..1b17ce61ae 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -62,6 +62,21 @@ As part of this upgrade, you may notice several visible changes due to Vuetify 4 * The grid system is now gap-based. * The default theme is now `system` instead of `light`. +### Vue keeps the state of a form shallow + +`JsonForms` of `@jsonforms/vue` now keeps its state shallow. +Vue no longer makes a proxy for each node of the `schema`, the `uischema`, the `renderers`, the `cells` and the form data, which makes a large form much faster to mount. + +JSON Forms gives the value of a prop to the state as it is. +An application that keeps such a value out of deep reactive state thus no longer needs `markRaw` for it, and Vue no longer gives the "received a Component that was made a reactive object" warning for a renderer set. +An application that keeps such a value in `reactive()` state gives a proxy of the value to the form. +Use `shallowRef`, `shallowReactive` or `markRaw` for a value that must stay unwrapped, such as a renderer set, for which Vue gives the warning above. +The one exception is `ajv`, which the form always unwraps, because Ajv cannot compile a schema through a proxy of itself. + +The form data that a renderer gets is no longer a proxy. +A change of the data thus needs a `dispatch` of an `update` action, which the `useJsonFormsControl` composition and its relatives do for you through `handleChange`. +A custom renderer that writes into the data object directly, for example with a `v-model` on a nested field, must use `handleChange` instead. + ## Migrating to JSON Forms 3.8 ### `Translator` type changed from overloaded signatures to a generic conditional type diff --git a/packages/vue-vuetify/dev/validate/index.ts b/packages/vue-vuetify/dev/validate/index.ts index c454e69279..5a1b95905a 100644 --- a/packages/vue-vuetify/dev/validate/index.ts +++ b/packages/vue-vuetify/dev/validate/index.ts @@ -1,5 +1,4 @@ import type { Options } from 'ajv'; -import { markRaw } from 'vue'; import { createAjv as createDefaultAjv } from '../../src'; import { ajvKeywords } from './keywords'; @@ -13,6 +12,5 @@ export const createAjv = () => { const ajv = createDefaultAjv(options); ajvKeywords(ajv); - // when ajv is used in component properties do not make it reactive - return markRaw(ajv); + return ajv; }; diff --git a/packages/vue-vuetify/dev/views/ExampleView.vue b/packages/vue-vuetify/dev/views/ExampleView.vue index b95099015e..bee442c683 100644 --- a/packages/vue-vuetify/dev/views/ExampleView.vue +++ b/packages/vue-vuetify/dev/views/ExampleView.vue @@ -5,7 +5,6 @@ import cloneDeep from 'lodash/cloneDeep'; import find from 'lodash/find'; import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; import { - markRaw, onMounted, provide, ref, @@ -66,7 +65,7 @@ const initialState = (exampleProp: ExampleDescription) => { // Get custom renderers for this example (if any) const customRenderers = getCustomRenderersForExample(example.name); - const renderers = markRaw([...customRenderers, ...extendedVuetifyRenderers]); + const renderers = [...customRenderers, ...extendedVuetifyRenderers]; return { data: example.data, @@ -284,10 +283,6 @@ const handleAction = (action: Action) => { if (action) { const newState = action.apply(state); if (newState) { - if (newState.renderers) { - newState.renderers = markRaw(newState.renderers); - } - Object.assign(state, newState); } } diff --git a/packages/vue-vuetify/src/complex/components/AdditionalProperties.vue b/packages/vue-vuetify/src/complex/components/AdditionalProperties.vue index d38df0b857..ce102a07af 100644 --- a/packages/vue-vuetify/src/complex/components/AdditionalProperties.vue +++ b/packages/vue-vuetify/src/complex/components/AdditionalProperties.vue @@ -126,7 +126,6 @@ import { IsDynamicPropertyContext } from '@/util/inject'; import { computed, defineComponent, - markRaw, provide, ref, unref, @@ -433,12 +432,12 @@ export default defineComponent({ return { validationMode: validationMode, - i18n: i18n ? markRaw(i18n) : i18n, - middleware: middleware ? markRaw(middleware) : middleware, + i18n, + middleware, t, mdAndUp, vuetifyProps, - ajv: ajv ? markRaw(ajv) : ajv, + ajv, control, styles, appliedOptions, diff --git a/packages/vue-vuetify/tests/unit/additional/AdditionalPropertiesAjv.spec.ts b/packages/vue-vuetify/tests/unit/additional/AdditionalPropertiesAjv.spec.ts index d99ae5a5e1..56eb58fa5f 100644 --- a/packages/vue-vuetify/tests/unit/additional/AdditionalPropertiesAjv.spec.ts +++ b/packages/vue-vuetify/tests/unit/additional/AdditionalPropertiesAjv.spec.ts @@ -1,6 +1,5 @@ import { describe, it, expect, beforeEach } from 'vitest'; import { clearAllIds, createAjv } from '@jsonforms/core'; -import { markRaw } from 'vue'; import { extendedVuetifyRenderers } from '../../../src'; import { mountJsonForms } from '../util/util'; @@ -27,7 +26,7 @@ describe('AdditionalProperties nested AJV', () => { it('mounts a map whose key pattern is only valid without the `u` flag', () => { // A parent form configured with `unicodeRegExp: false` - const ajv = markRaw(createAjv({ unicodeRegExp: false })); + const ajv = createAjv({ unicodeRegExp: false }); expect(() => mountJsonForms( { secretFiles: {} }, diff --git a/packages/vue-vuetify/tests/unit/util/util.ts b/packages/vue-vuetify/tests/unit/util/util.ts index 00c63a83fd..ccd6c11abf 100644 --- a/packages/vue-vuetify/tests/unit/util/util.ts +++ b/packages/vue-vuetify/tests/unit/util/util.ts @@ -10,7 +10,6 @@ import TestComponent from './TestComponent.vue'; import { createVuetify } from 'vuetify'; import * as components from 'vuetify/components'; import * as directives from 'vuetify/directives'; -import { markRaw } from 'vue'; const vuetify = createVuetify({ components, @@ -37,7 +36,7 @@ export const mountJsonForms = ( schema, uischema, config, - renderers: markRaw(renderers), + renderers, i18n, ajv, }, diff --git a/packages/vue/src/components/JsonForms.vue b/packages/vue/src/components/JsonForms.vue index 9473db176c..dfc7aec7ab 100644 --- a/packages/vue/src/components/JsonForms.vue +++ b/packages/vue/src/components/JsonForms.vue @@ -27,7 +27,14 @@ import { ValidationMode, } from '@jsonforms/core'; import isEqual from 'lodash/isEqual'; -import { defineComponent, PropType, reactive, toRaw } from 'vue'; +import { + defineComponent, + PropType, + reactive, + shallowReactive, + shallowRef, + toRaw, +} from 'vue'; import { JsonFormsChangeEvent, MaybeReadonly } from '../types'; import DispatchRenderer from './DispatchRenderer.vue'; @@ -120,6 +127,19 @@ export default defineComponent({ }, }, emits: ['change', 'update:data'], + /** + * The state of a form is shallow. + * + * JSON Forms only reads the schema and the UI schema, thus Vue does not need + * to make them reactive. A deep proxy made a new proxy for each nested schema + * node at the first read of that node. Testers and the scope resolution read + * the schema many times for each control, thus these proxies made a large + * form slow to mount. + * + * `shallowRef` and `shallowReactive` keep the objects of the application as + * they are. A reducer replaces `core` for each change and never changes it in + * place, thus shallow tracking is sufficient. + */ data() { const dataToUse = this.data; const schemaToUse: JsonSchema = @@ -135,7 +155,8 @@ export default defineComponent({ initialCore, Actions.init(dataToUse, schemaToUse, uischemaToUse, { validationMode: this.validationMode, - ajv: this.ajv, + // Ajv cannot compile a schema through a proxy of itself. + ajv: toRaw(this.ajv), additionalErrors: this.additionalErrors, }), coreReducer @@ -143,10 +164,10 @@ export default defineComponent({ return core; }; return { - schemaToUse, - dataToUse, - uischemaToUse, - jsonforms: { + schemaToUse: shallowRef(schemaToUse), + dataToUse: shallowRef(dataToUse), + uischemaToUse: shallowRef(uischemaToUse), + jsonforms: shallowReactive({ core: initCore(), config: configReducer(undefined, Actions.setConfig(this.config)), i18n: i18nReducer( @@ -161,7 +182,7 @@ export default defineComponent({ cells: this.cells, uischemas: this.uischemas, readonly: this.readonly, - }, + }), }; }, computed: { @@ -193,7 +214,8 @@ export default defineComponent({ this.uischemaToUse = newUischema ?? generateUISchema(this.schemaToUse); }, data(newData) { - const isSameAsCurrentData = newData === this.jsonforms.core.data; + const isSameAsCurrentData = + toRaw(newData) === toRaw(this.jsonforms.core.data); this.dataToUse = newData; if ( @@ -239,7 +261,8 @@ export default defineComponent({ this.uischemaToUse, { validationMode: this.validationMode, - ajv: this.ajv, + // Ajv cannot compile a schema through a proxy of itself. + ajv: toRaw(this.ajv), additionalErrors: this.additionalErrors, } ), diff --git a/packages/vue/tests/unit/JsonForms.spec.ts b/packages/vue/tests/unit/JsonForms.spec.ts index 1a49500952..c3c5edd563 100644 --- a/packages/vue/tests/unit/JsonForms.spec.ts +++ b/packages/vue/tests/unit/JsonForms.spec.ts @@ -1,14 +1,48 @@ import { Actions, JsonFormsUISchemaRegistryEntry, + JsonFormsRendererRegistryEntry, + JsonFormsCellRendererRegistryEntry, Generate, Middleware, + createAjv, } from '@jsonforms/core'; -import { shallowMount } from '@vue/test-utils'; -import { nextTick } from 'vue'; +import { + defineComponent, + h, + isReactive, + nextTick, + reactive, + shallowReactive, + watch, +} from 'vue'; +import { flushPromises, mount, shallowMount } from '@vue/test-utils'; import { JsonForms } from '../../src'; import { bindings } from '../testHelper'; +/** + * Mounts a form as a child of an application. + * + * `@vue/test-utils` keeps the props of a mount in `reactive()`, thus a plain + * object of a test reaches `JsonForms` as a proxy. Vue keeps the props of a + * component shallow, thus a parent gives the object itself. The + * `shallowReactive` state of this parent replaces a prop. + */ +const mountInParent = (props: Record) => { + const state = shallowReactive({ ...props }); + const parent = mount( + defineComponent({ + render: () => h(JsonForms as any, { ...state }), + }) + ); + const vm = () => parent.findComponent(JsonForms).vm as any; + return { + state, + jsonforms: () => vm().jsonforms, + core: () => vm().jsonforms.core, + }; +}; + describe('JsonForms.vue', () => { it('uses undefined as schema prop when not given', () => { const data = { number: 5 }; @@ -311,4 +345,168 @@ describe('JsonForms.vue', () => { expect((wrapper.vm as any).schemaToUse).toBe(initialSchema); expect((wrapper.vm as any).uischemaToUse).toBe(initialUiSchema); }); + + it('adds no reactivity to the given schema and ui schema', () => { + const data = { number: 5.5 }; + const schema = { + type: 'object', + properties: { number: { type: 'number' } }, + }; + const uischema = { + type: 'Control', + scope: '#/properties/number', + }; + const renderers: JsonFormsUISchemaRegistryEntry[] = []; + const form = mountInParent({ data, schema, uischema, renderers }); + const core = form.core(); + + expect(isReactive(core.schema)).toBe(false); + expect(isReactive(core.uischema)).toBe(false); + // A renderer gets the original nested nodes, and not proxies of them. + expect(core.schema).toBe(schema); + expect(core.schema.properties.number).toBe(schema.properties.number); + expect(core.uischema).toBe(uischema); + expect(isReactive(core.data)).toBe(false); + expect(core.data).toBe(data); + }); + + it('adds no reactivity to a generated schema and ui schema', () => { + const data = { number: 5.5 }; + const renderers: JsonFormsUISchemaRegistryEntry[] = []; + const core = mountInParent({ data, renderers }).core(); + + expect(isReactive(core.schema)).toBe(false); + expect(isReactive(core.uischema)).toBe(false); + }); + + it('applies a new schema prop to the core state', async () => { + const data = { number: 5.5 }; + const schema = { + type: 'object', + properties: { number: { type: 'number' } }, + }; + const newSchema = { + type: 'object', + properties: { number: { type: 'string' } }, + }; + const renderers: JsonFormsUISchemaRegistryEntry[] = []; + const form = mountInParent({ data, schema, renderers }); + expect(form.core().schema).toBe(schema); + expect(form.core().errors).toHaveLength(0); + + form.state.schema = newSchema; + await flushPromises(); + + expect(form.core().schema).toBe(newSchema); + // The validation runs again for the new schema. + expect(form.core().errors).toHaveLength(1); + }); + + it('applies a new ui schema prop to the core state', async () => { + const data = { number: 5.5 }; + const schema = { + type: 'object', + properties: { number: { type: 'number' } }, + }; + const uischema = { type: 'Control', scope: '#/properties/number' }; + const newUischema = { + type: 'VerticalLayout', + elements: [{ type: 'Control', scope: '#/properties/number' }], + }; + const renderers: JsonFormsUISchemaRegistryEntry[] = []; + const form = mountInParent({ data, schema, uischema, renderers }); + expect(form.core().uischema).toBe(uischema); + + form.state.uischema = newUischema; + await flushPromises(); + + expect(form.core().uischema).toBe(newUischema); + }); + + it('adds no reactivity to the renderers and the cells', async () => { + const data = { number: 5.5 }; + const stub = { name: 'Stub', template: '
' }; + const renderers: JsonFormsRendererRegistryEntry[] = [ + { tester: () => -1, renderer: stub }, + ]; + const cells: JsonFormsCellRendererRegistryEntry[] = [ + { tester: () => -1, cell: stub }, + ]; + const newRenderers: JsonFormsRendererRegistryEntry[] = [ + { tester: () => 1, renderer: stub }, + ]; + const form = mountInParent({ data, renderers, cells }); + + // A reactive renderer entry gives the Vue warning for a reactive + // component, thus an application would need `markRaw` for its set. + expect(form.jsonforms().renderers).toBe(renderers); + expect(form.jsonforms().renderers[0].renderer).toBe(stub); + expect(isReactive(form.jsonforms().renderers)).toBe(false); + expect(form.jsonforms().cells).toBe(cells); + expect(isReactive(form.jsonforms().cells)).toBe(false); + + form.state.renderers = newRenderers; + await flushPromises(); + + expect(form.jsonforms().renderers).toBe(newRenderers); + expect(isReactive(form.jsonforms().renderers)).toBe(false); + }); + + it('adds no reactivity to ajv', () => { + const data = { number: 5.5 }; + const ajv = createAjv(); + const renderers: JsonFormsUISchemaRegistryEntry[] = []; + const core = mountInParent({ data, ajv, renderers }).core(); + + // Ajv cannot compile a schema through a proxy of itself. + expect(core.ajv).toBe(ajv); + expect(isReactive(core.ajv)).toBe(false); + }); + + it('unwraps an ajv that comes from reactive state', () => { + const data = { number: 5.5 }; + const ajv = createAjv(); + const renderers: JsonFormsUISchemaRegistryEntry[] = []; + // An application that keeps `ajv` in `reactive()` gives a proxy of it. + const core = mountInParent({ data, ajv: reactive(ajv), renderers }).core(); + + // Ajv cannot compile a schema through a proxy of itself. + expect(core.ajv).toBe(ajv); + expect(core.errors).toHaveLength(0); + }); + + it('adds no reactivity to a generated ajv', () => { + const data = { number: 5.5 }; + const renderers: JsonFormsUISchemaRegistryEntry[] = []; + const core = mountInParent({ data, renderers }).core(); + + expect(core.ajv).toBeDefined(); + expect(isReactive(core.ajv)).toBe(false); + }); + + it('leaves the objects of the application untouched', async () => { + const data = { number: 5.5 }; + const schema = { + type: 'object', + properties: { number: { type: 'number' } as Record }, + }; + const state = reactive({ schema }); + let deepChanges = 0; + watch( + () => state.schema, + () => { + deepChanges++; + }, + { deep: true } + ); + const renderers: JsonFormsUISchemaRegistryEntry[] = []; + mountInParent({ data, schema: state.schema, renderers }); + + // JSON Forms keeps its own state shallow. It writes no flag on the object + // of the application, thus a deep watcher of the application still runs. + expect((schema as Record).__v_skip).toBeUndefined(); + state.schema.properties.number.title = 'Number'; + await nextTick(); + expect(deepChanges).toBe(1); + }); }); From 7d6b5185c2a7ff5a71493a1eb1379f327d3df95d Mon Sep 17 00:00:00 2001 From: cinereal Date: Sun, 18 Oct 2026 11:34:30 +0200 Subject: [PATCH 2/3] fix(vue): unwrap the initial data, schema and UI schema An application that keeps the `data`, the `schema` or the `uischema` in `reactive()` state gives a proxy of it to `JsonForms`. The watchers of these props already get the plain object, because the reactive `set` trap of the state calls `toRaw`. `data()` did not unwrap the initial values, thus the form started with proxies and made the deep proxies again. `data()` and the watchers now apply `toRaw` to these values, thus the form always works on the plain objects. Assisted-by: Claude:claude-opus-5-5 Claude-Session: https://claude.ai/code/session_01ABEfryjEao6ftncdw48d6V --- MIGRATION.md | 10 ++--- packages/vue/src/components/JsonForms.vue | 21 ++++++----- packages/vue/tests/unit/JsonForms.spec.ts | 45 +++++++++++++++++++++++ 3 files changed, 62 insertions(+), 14 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index 1b17ce61ae..7eed4d8b55 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -67,11 +67,11 @@ As part of this upgrade, you may notice several visible changes due to Vuetify 4 `JsonForms` of `@jsonforms/vue` now keeps its state shallow. Vue no longer makes a proxy for each node of the `schema`, the `uischema`, the `renderers`, the `cells` and the form data, which makes a large form much faster to mount. -JSON Forms gives the value of a prop to the state as it is. -An application that keeps such a value out of deep reactive state thus no longer needs `markRaw` for it, and Vue no longer gives the "received a Component that was made a reactive object" warning for a renderer set. -An application that keeps such a value in `reactive()` state gives a proxy of the value to the form. -Use `shallowRef`, `shallowReactive` or `markRaw` for a value that must stay unwrapped, such as a renderer set, for which Vue gives the warning above. -The one exception is `ajv`, which the form always unwraps, because Ajv cannot compile a schema through a proxy of itself. +The form unwraps a proxy of the `data`, the `schema`, the `uischema` and `ajv` with `toRaw`, and gives the other props to the state as they are. +JSON Forms writes no flag on the objects of the application. +An application that keeps the `renderers`, the `cells` or the `uischemas` out of deep reactive state thus no longer needs `markRaw` for them, and Vue no longer gives the "received a Component that was made a reactive object" warning for a renderer set. +An application that keeps them in `reactive()` state gives a proxy of them to the form. +Use `shallowRef`, `shallowReactive` or `markRaw` for a renderer set, for which Vue gives the warning above. The form data that a renderer gets is no longer a proxy. A change of the data thus needs a `dispatch` of an `update` action, which the `useJsonFormsControl` composition and its relatives do for you through `handleChange`. diff --git a/packages/vue/src/components/JsonForms.vue b/packages/vue/src/components/JsonForms.vue index dfc7aec7ab..183edb9532 100644 --- a/packages/vue/src/components/JsonForms.vue +++ b/packages/vue/src/components/JsonForms.vue @@ -136,15 +136,16 @@ export default defineComponent({ * the schema many times for each control, thus these proxies made a large * form slow to mount. * - * `shallowRef` and `shallowReactive` keep the objects of the application as - * they are. A reducer replaces `core` for each change and never changes it in - * place, thus shallow tracking is sufficient. + * `toRaw` unwraps a proxy of the data, the schema and the UI schema, thus the + * form always works on the plain objects. `shallowRef` and `shallowReactive` + * keep these objects as they are. A reducer replaces `core` for each change + * and never changes it in place, thus shallow tracking is sufficient. */ data() { - const dataToUse = this.data; + const dataToUse = toRaw(this.data); const schemaToUse: JsonSchema = - this.schema ?? Generate.jsonSchema(dataToUse); - const uischemaToUse = this.uischema ?? generateUISchema(schemaToUse); + toRaw(this.schema) ?? Generate.jsonSchema(dataToUse); + const uischemaToUse = toRaw(this.uischema) ?? generateUISchema(schemaToUse); const initCore = (): JsonFormsCore => { const initialCore = { data: dataToUse, @@ -205,18 +206,20 @@ export default defineComponent({ }, watch: { schema(newSchema) { - this.schemaToUse = newSchema ?? Generate.jsonSchema(this.dataToUse); + this.schemaToUse = + toRaw(newSchema) ?? Generate.jsonSchema(this.dataToUse); if (!this.uischema) { this.uischemaToUse = generateUISchema(this.schemaToUse); } }, uischema(newUischema) { - this.uischemaToUse = newUischema ?? generateUISchema(this.schemaToUse); + this.uischemaToUse = + toRaw(newUischema) ?? generateUISchema(this.schemaToUse); }, data(newData) { const isSameAsCurrentData = toRaw(newData) === toRaw(this.jsonforms.core.data); - this.dataToUse = newData; + this.dataToUse = toRaw(newData); if ( (this.schema === undefined || this.schema === null) && diff --git a/packages/vue/tests/unit/JsonForms.spec.ts b/packages/vue/tests/unit/JsonForms.spec.ts index c3c5edd563..6a1ef0cc1b 100644 --- a/packages/vue/tests/unit/JsonForms.spec.ts +++ b/packages/vue/tests/unit/JsonForms.spec.ts @@ -475,6 +475,51 @@ describe('JsonForms.vue', () => { expect(core.errors).toHaveLength(0); }); + it('unwraps a data, schema and ui schema that come from reactive state', () => { + const data = { number: 5.5 }; + const schema = { + type: 'object', + properties: { number: { type: 'number' } }, + }; + const uischema = { + type: 'Control', + scope: '#/properties/number', + }; + const renderers: JsonFormsUISchemaRegistryEntry[] = []; + // An application that keeps these values in `reactive()` gives proxies of + // them. + const state = reactive({ data, schema, uischema }); + const core = mountInParent({ ...state, renderers }).core(); + + expect(core.data).toBe(data); + expect(core.schema).toBe(schema); + expect(core.uischema).toBe(uischema); + }); + + it('unwraps a new data, schema and ui schema that come from reactive state', async () => { + const renderers: JsonFormsUISchemaRegistryEntry[] = []; + const form = mountInParent({ data: { number: 5.5 }, renderers }); + const data = { number: 6 }; + const schema = { + type: 'object', + properties: { number: { type: 'number' } }, + }; + const uischema = { + type: 'Control', + scope: '#/properties/number', + }; + const state = reactive({ data, schema, uischema }); + form.state.data = state.data; + form.state.schema = state.schema; + form.state.uischema = state.uischema; + await nextTick(); + + const core = form.core(); + expect(core.data).toBe(data); + expect(core.schema).toBe(schema); + expect(core.uischema).toBe(uischema); + }); + it('adds no reactivity to a generated ajv', () => { const data = { number: 5.5 }; const renderers: JsonFormsUISchemaRegistryEntry[] = []; From c7ae97d698235440ab910b106735fbc11e898aef Mon Sep 17 00:00:00 2001 From: cinereal Date: Sun, 18 Oct 2026 11:38:33 +0200 Subject: [PATCH 3/3] test(vue-vuetify): mark the renderers of a test form raw `@vue/test-utils` keeps the props of a mount in `reactive()`, thus the renderers get to `JsonForms` as a proxy. Vue then gives the "received a Component that was made a reactive object" warning 120 times in the tests of `@jsonforms/vue-vuetify`. `mountJsonForms` applies `markRaw` to the renderers again. Assisted-by: Claude:claude-opus-5-5 Claude-Session: https://claude.ai/code/session_01ABEfryjEao6ftncdw48d6V --- packages/vue-vuetify/tests/unit/util/util.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/vue-vuetify/tests/unit/util/util.ts b/packages/vue-vuetify/tests/unit/util/util.ts index ccd6c11abf..00c63a83fd 100644 --- a/packages/vue-vuetify/tests/unit/util/util.ts +++ b/packages/vue-vuetify/tests/unit/util/util.ts @@ -10,6 +10,7 @@ import TestComponent from './TestComponent.vue'; import { createVuetify } from 'vuetify'; import * as components from 'vuetify/components'; import * as directives from 'vuetify/directives'; +import { markRaw } from 'vue'; const vuetify = createVuetify({ components, @@ -36,7 +37,7 @@ export const mountJsonForms = ( schema, uischema, config, - renderers, + renderers: markRaw(renderers), i18n, ajv, },