Skip to content

Commit 03920de

Browse files
authored
ScriptAttribute fix (#6750)
* Added guard around attribute assignment. Exposes attrToValue as static method * linting fixes
1 parent c930e39 commit 03920de

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/framework/script/script-attributes.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,18 @@ function attributeToValue(app, schema, value, current) {
180180
*/
181181
export function assignAttributesToScript(app, attributeSchemaMap, data, script) {
182182

183+
if (!data) return;
184+
183185
// Iterate over the schema and assign corresponding data
184186
for (const attributeName in attributeSchemaMap) {
185187
const attributeSchema = attributeSchemaMap[attributeName];
186188
const dataToAssign = data[attributeName];
187189

190+
// Skip if the data is not defined
191+
if (dataToAssign === undefined) continue;
192+
188193
// Assign the value to the script based on the attribute schema
189-
script[attributeName] = attributeToValue(app, attributeSchema, dataToAssign, script);
194+
script[attributeName] = attributeToValue(app, attributeSchema, dataToAssign, script[attributeName]);
190195
}
191196
}
192197

@@ -200,6 +205,8 @@ export function assignAttributesToScript(app, attributeSchemaMap, data, script)
200205
class ScriptAttributes {
201206
static assignAttributesToScript = assignAttributesToScript;
202207

208+
static attributeToValue = attributeToValue;
209+
203210
/**
204211
* Create a new ScriptAttributes instance.
205212
*

0 commit comments

Comments
 (0)