Browse Source

Throw an error if trying to access a data variable with undefined em

em-data-variables
mohamed yahia 1 year ago
parent
commit
f81d8bbc44
  1. 7
      packages/core/src/data_sources/model/DataVariable.ts

7
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;
}

Loading…
Cancel
Save