diff --git a/packages/core/src/dom_components/model/ModelResolverWatcher.ts b/packages/core/src/dom_components/model/ModelResolverWatcher.ts index ccf9fba63..e9055c9f3 100644 --- a/packages/core/src/dom_components/model/ModelResolverWatcher.ts +++ b/packages/core/src/dom_components/model/ModelResolverWatcher.ts @@ -53,12 +53,13 @@ export class ModelResolverWatcher { addDataValues(values: ObjectAny | undefined, options: DataWatchersOptions = {}) { if (!values) return {}; - values = this.applyImportPolicy(values, options); - const evaluatedValues = this.evaluateValues(values); + const nextValues = this.applyImportPolicy(values, options); + if (!nextValues) return {}; + const evaluatedValues = this.evaluateValues(nextValues); const shouldSkipWatcherUpdates = options.skipWatcherUpdates || options.fromDataSource; if (!shouldSkipWatcherUpdates) { - this.updateListeners(values); + this.updateListeners(nextValues); } return evaluatedValues; diff --git a/packages/core/test/specs/data_sources/import_policy.ts b/packages/core/test/specs/data_sources/import_policy.ts index edd0dc1ca..9699056bb 100644 --- a/packages/core/test/specs/data_sources/import_policy.ts +++ b/packages/core/test/specs/data_sources/import_policy.ts @@ -34,6 +34,14 @@ const makeConditionVar = () => ({ ifFalse: 'blue', }); +type BaseRecord = { + id: string; + title: string; + color: string; + content: string; + mutable?: boolean; +}; + describe('Data source import policy', () => { let editor: Editor; let em: EditorModel; @@ -45,7 +53,7 @@ describe('Data source import policy', () => { }; const addBaseDataSource = ( - record = { id: 'rec1', title: 'Initial Title', color: 'red', content: 'Dynamic Content' }, + record: BaseRecord = { id: 'rec1', title: 'Initial Title', color: 'red', content: 'Dynamic Content' }, ) => { dsm.add({ id: 'records',