Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScriptAttribute fix #6750

Merged
merged 4 commits into from
Jun 25, 2024
Next Next commit
Added guard around attribute assignment. Exposes attrToValue as stati…
…c method
  • Loading branch information
marklundin committed Jun 25, 2024
commit f494258a367a1e7d012849bbbe970b985568a777
8 changes: 7 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 @@ -199,6 +204,7 @@ export function assignAttributesToScript(app, attributeSchemaMap, data, script)
*/
class ScriptAttributes {
static assignAttributesToScript = assignAttributesToScript;
static attributeToValue = attributeToValue;

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