Mercurial Hosting > sceditor
diff src/sceditor.js @ 29:ea32a44b5a6e
remove more oo
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 11 Aug 2022 19:54:03 -0600 |
parents | f227fdfebded |
children | db061869f28f |
line wrap: on
line diff
--- a/src/sceditor.js Thu Aug 11 00:04:48 2022 -0600 +++ b/src/sceditor.js Thu Aug 11 19:54:03 2022 -0600 @@ -2879,14 +2879,14 @@ * @private */ var callHandlers = function (args, returnAtFirst) { - args = [].slice.call(args); + if( args.length > 3 ) throw 'too many args'; var idx, ret, - signal = formatSignalName(args.shift()); + signal = formatSignalName(args[0]); for (idx = 0; idx < registeredPlugins.length; idx++) { if (signal in registeredPlugins[idx]) { - ret = registeredPlugins[idx][signal].apply(thisObj, args); + ret = registeredPlugins[idx][signal](thisObj, args[1], args[2]); if (returnAtFirst) { return ret; @@ -2996,16 +2996,17 @@ * @name register * @memberOf PluginManager.prototype */ - base.register = function (plugin) { - if (!base.exists(plugin) || base.isRegistered(plugin)) { + base.register = function (pluginName) { + if (!base.exists(pluginName) || base.isRegistered(pluginName)) { return false; } - plugin = new plugins[plugin](); + let plugin = plugins[pluginName](); + if(!plugin) throw pluginName; registeredPlugins.push(plugin); if ('init' in plugin) { - plugin.init.call(thisObj); + plugin.init(thisObj); } return true; @@ -3035,7 +3036,7 @@ removed = true; if ('destroy' in removedPlugin) { - removedPlugin.destroy.call(thisObj); + removedPlugin.destroy(thisObj); } } } @@ -3057,7 +3058,7 @@ while (i--) { if ('destroy' in registeredPlugins[i]) { - registeredPlugins[i].destroy.call(thisObj); + registeredPlugins[i].destroy(thisObj); } }