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

Add support for assigning properties to script instances #6787

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/framework/components/script/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,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 @@ -696,6 +697,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