Skip to content

Commit

Permalink
Add support for assigning properties to script instances (#6787)
Browse files Browse the repository at this point in the history
* Add support for assigning properties to script instances

* lint
  • Loading branch information
marklundin authored Aug 30, 2024
1 parent 5be4181 commit e20814a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/framework/components/script/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ class ScriptComponent extends Component {
* true.
* @param {object} [args.attributes] - Object with values for attributes (if any), where key is
* name of an attribute.
* @param {object} [args.properties] - Object with values that are **assigned** to the script instance.
* @param {boolean} [args.preloading] - If script instance is created during preload. If true,
* script and attributes must be initialized manually. Defaults to false.
* @param {number} [args.ind] - The index where to insert the script instance at. Defaults to
Expand Down Expand Up @@ -702,6 +703,9 @@ class ScriptComponent extends Component {
attributes: args.attributes
});

if (args.properties && typeof args.properties === 'object') {
Object.assign(scriptInstance, args.properties);
}

// If the script is not a ScriptType then we must store attribute data on the component
if (!(scriptInstance instanceof ScriptType)) {
Expand Down

0 comments on commit e20814a

Please sign in to comment.