diff --git a/README.md b/README.md index 1f271d8..287388f 100755 --- a/README.md +++ b/README.md @@ -517,6 +517,9 @@ Attribute access: .getActionAttr('action', 'attr') -> +.getActionAttrAliased('action', 'attr') + -> + .getRootActionAttr('action', 'attr') -> ``` diff --git a/actions.js b/actions.js index 54f83dd..908909b 100755 --- a/actions.js +++ b/actions.js @@ -1048,6 +1048,29 @@ module.MetaActions = { if(cur[action] != null && action != '__actioncall__'){ return this.getActionAttr('__actioncall__', attr) } }, + // Get action attribute with alias support... + // + // An aliased attribute is one containing a string name of another + // action. + // + // To avoid things changing when actions are added/removed this does + // not support string attrubute values. + getActionAttrAliased: function(action, attr){ + var value = action + var seen = new Set() + do { + // recursive alias... + if(seen.has(value)){ + throw new Error( + 'getActionAttrAliased: recursive alias for "'+ attr +'": ' + // XXX should we split seen at value??? + + [...seen, value].join(' -> ')) } + seen.add(value) + // next value... + value = this.getActionAttr(value, attr) + } while(typeof(value) == 'string') + return value }, + // Get root action attribute value... // // This is similar to .getActionAttr(..) but will only chenck the diff --git a/package.json b/package.json index 1db2c93..d28ab05 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-actions", - "version": "3.24.30", + "version": "3.25.0", "description": "", "main": "actions.js", "scripts": {