bugfix...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-04-29 07:49:21 +03:00
parent 21ddea3e50
commit 383e98416a
2 changed files with 23 additions and 15 deletions

View File

@ -646,7 +646,7 @@ object.Constructor('Action', {
// Action(<name>, [ [<doc>[, <long-doc>]][, <attrs>,] <function> ]) // Action(<name>, [ [<doc>[, <long-doc>]][, <attrs>,] <function> ])
// -> <action> // -> <action>
// //
__new__: function Action(context, name, doc, ldoc, attrs, func){ __new__: function(context, name, doc, ldoc, attrs, func){
// prevent action overloading... // prevent action overloading...
// XXX do we need this??? // XXX do we need this???
//if(context != null && context[name] != null){ //if(context != null && context[name] != null){
@ -661,8 +661,8 @@ object.Constructor('Action', {
var args = doc instanceof Array ? var args = doc instanceof Array ?
doc doc
: [...arguments] : [...arguments]
.slice(2)
.filter(function(e){ return e !== undefined }) .filter(function(e){ return e !== undefined })
.slice(1)
func = args.pop() func = args.pop()
last = args[args.length-1] last = args[args.length-1]
attrs = (last != null && typeof(last) != typeof('str')) ? attrs = (last != null && typeof(last) != typeof('str')) ?
@ -732,26 +732,36 @@ module.Alias =
object.Constructor('Alias', { object.Constructor('Alias', {
__proto__: Action.prototype, __proto__: Action.prototype,
__new__: function Alias(context, alias, doc, ldoc, attrs, target){ __new__: function(context, alias, doc, ldoc, attrs, target){
// precess args... // precess args...
var args = doc instanceof Array ? var args = doc instanceof Array ?
doc doc
: [...arguments] : [...arguments]
.slice(2)
.filter(function(e){ return e !== undefined }) .filter(function(e){ return e !== undefined })
.slice(1)
target = args.pop() target = args.pop()
last = args[args.length-1] last = args[args.length-1]
attrs = last != null && typeof(last) != typeof('str') ? args.pop() : {} attrs = (last != null && typeof(last) != typeof('str')) ?
doc = typeof(args[0]) == typeof('str') ? args.shift() : null args.pop()
ldoc = typeof(args[0]) == typeof('str') ? args.shift() : null : {}
doc = typeof(args[0]) == typeof('str') ?
args.shift()
: null
ldoc = typeof(args[0]) == typeof('str') ?
args.shift()
: null
attrs.alias = target attrs.alias = target
// NOTE: we are not parsing this directly here because the context // NOTE: we are not parsing this directly here because the context
// may define a different .parseStringAction(..) // may define a different .parseStringAction(..)
var parsed = typeof(target) == typeof('str') ? null : target var parsed = typeof(target) == typeof('str') ?
null
: target
doc = (!doc && parsed) ? parsed.doc : doc doc = (!doc && parsed) ?
parsed.doc
: doc
var func = function(){ var func = function(){
// empty alias... // empty alias...
@ -769,15 +779,13 @@ object.Constructor('Alias', {
return p.action in this ? return p.action in this ?
(this.parseStringAction || parseStringAction).callAction(this, p, ...in_args) (this.parseStringAction || parseStringAction).callAction(this, p, ...in_args)
// error... // error...
: console.error(`${alias}: Unknown alias target action: ${p.action}`) : console.error(`${alias}: Unknown alias target action: ${p.action}`) }
}
func.toString = function(){ func.toString = function(){
return meth.alias.code || meth.alias } return meth.alias.code || meth.alias }
// make the action... // make the action...
// XXX not sure this is the correct way to go... var meth = object.parentCall(Alias.prototype.__new__, this, context, alias, doc, ldoc, attrs, func)
var meth = this.__proto__.__new__.call(this, context, alias, doc, ldoc, attrs, func) //meth.__proto__ = this.__proto__
meth.__proto__ = this.__proto__
meth.func.alias = target meth.func.alias = target

View File

@ -1,6 +1,6 @@
{ {
"name": "ig-actions", "name": "ig-actions",
"version": "3.24.8", "version": "3.24.9",
"description": "", "description": "",
"main": "actions.js", "main": "actions.js",
"scripts": { "scripts": {