Skip to content

Commit

Permalink
ScriptAttribute fix (#6750)
Browse files Browse the repository at this point in the history
* Added guard around attribute assignment. Exposes attrToValue as static method

* linting fixes
  • Loading branch information
marklundin authored Jun 25, 2024
1 parent c930e39 commit 03920de
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/framework/script/script-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,18 @@ function attributeToValue(app, schema, value, current) {
*/
export function assignAttributesToScript(app, attributeSchemaMap, data, script) {

if (!data) return;

// Iterate over the schema and assign corresponding data
for (const attributeName in attributeSchemaMap) {
const attributeSchema = attributeSchemaMap[attributeName];
const dataToAssign = data[attributeName];

// Skip if the data is not defined
if (dataToAssign === undefined) continue;

// Assign the value to the script based on the attribute schema
script[attributeName] = attributeToValue(app, attributeSchema, dataToAssign, script);
script[attributeName] = attributeToValue(app, attributeSchema, dataToAssign, script[attributeName]);
}
}

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

static attributeToValue = attributeToValue;

/**
* Create a new ScriptAttributes instance.
*
Expand Down

0 comments on commit 03920de

Please sign in to comment.