added .getActionAttrAliased(..)

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-02-18 01:18:05 +03:00
parent fdf953d791
commit 47dac0a351
3 changed files with 27 additions and 1 deletions

View File

@ -517,6 +517,9 @@ Attribute access:
<action-set>.getActionAttr('action', 'attr') <action-set>.getActionAttr('action', 'attr')
-> <value> -> <value>
<action-set>.getActionAttrAliased('action', 'attr')
-> <value>
<action-set>.getRootActionAttr('action', 'attr') <action-set>.getRootActionAttr('action', 'attr')
-> <value> -> <value>
``` ```

View File

@ -1048,6 +1048,29 @@ module.MetaActions = {
if(cur[action] != null && action != '__actioncall__'){ if(cur[action] != null && action != '__actioncall__'){
return this.getActionAttr('__actioncall__', attr) } }, 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... // Get root action attribute value...
// //
// This is similar to .getActionAttr(..) but will only chenck the // This is similar to .getActionAttr(..) but will only chenck the

View File

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