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

ES6 createScript #6147

Merged
merged 2 commits into from
Apr 16, 2024
Merged
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
18 changes: 5 additions & 13 deletions src/framework/script/script-create.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Debug } from '../../core/debug.js';
import { EventHandler } from '../../core/event-handler.js';

import { script } from '../script.js';
import { AppBase } from '../app-base.js';
Expand Down Expand Up @@ -65,19 +64,12 @@ function createScript(name, app) {
if (reservedScriptNames.has(name))
throw new Error(`Script name '${name}' is reserved, please rename the script`);

const scriptType = function (args) {
EventHandler.prototype.initEventHandler.call(this);
Script.prototype.initScriptType.call(this, args);
};

scriptType.prototype = Object.create(Script.prototype);
scriptType.prototype.constructor = scriptType;

scriptType.extend = Script.extend;
scriptType.attributes = new ScriptAttributes(scriptType);
class ScriptWithAttributes extends Script {
attributes = new ScriptAttributes(ScriptWithAttributes);
}

registerScript(scriptType, name, app);
return scriptType;
registerScript(ScriptWithAttributes, name, app);
return ScriptWithAttributes;
}

// Editor uses this - migrate to ScriptAttributes.reservedNames and delete this
Expand Down