From f81d8bbc44760a1eb150d33020be7035b0f2a963 Mon Sep 17 00:00:00 2001 From: mohamed yahia Date: Fri, 25 Oct 2024 09:20:46 +0300 Subject: [PATCH] Throw an error if trying to access a data variable with undefined em --- packages/core/src/data_sources/model/DataVariable.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/core/src/data_sources/model/DataVariable.ts b/packages/core/src/data_sources/model/DataVariable.ts index a03e1d677..9e70b93b6 100644 --- a/packages/core/src/data_sources/model/DataVariable.ts +++ b/packages/core/src/data_sources/model/DataVariable.ts @@ -5,7 +5,7 @@ import { stringToPath } from '../../utils/mixins'; export const DataVariableType = 'data-variable'; export default class DataVariable extends Model { - em?: EditorModel; + em: EditorModel; defaults() { return { @@ -37,7 +37,10 @@ export default class DataVariable extends Model { getDataValue() { const { path, defaultValue } = this.attributes; - const val = this.em?.DataSources.getValue(path, defaultValue); + if (!this.em) { + throw new Error('EditorModel instance is not provided for a data variable.'); + } + const val = this.em.DataSources.getValue(path, defaultValue); return val; }