From e9df17667b0720872b5f6b7d6cdd07af4d3da4a1 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 29 Dec 2016 22:41:03 +0300 Subject: [PATCH] added ability to set action attrs... Signed-off-by: Alex A. Naanou --- actions.js | 13 ++++++++++++- package.json | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/actions.js b/actions.js index 11e5b27..df7ae5d 100755 --- a/actions.js +++ b/actions.js @@ -1436,6 +1436,7 @@ object.makeConstructor('ActionSet', MetaActions) // : [ // , // , +// , // // ], // @@ -1454,6 +1455,8 @@ object.makeConstructor('ActionSet', MetaActions) // // // NOTE: the action function is always last. +// NOTE: if given must be right before the function and must not +// be a string... // NOTE: if is not given, MetaActions will be used as default. // // For more documentation see: Action(..). @@ -1490,8 +1493,16 @@ function Actions(a, b){ var func = arg.pop() + // attrs... + var last = arg[arg.length-1] + var attrs = last != null && typeof(last) != typeof('str') ? arg.pop() : {} + // create a new action... - obj[k] = new Action(k, arg[0], arg[1], func) + var a = obj[k] = new Action(k, arg[0], arg[1], func) + + // setup attrs... + Object.keys(attrs) + .forEach(function(k){ a[k] = attrs[k] }) }) if(proto != null){ diff --git a/package.json b/package.json index 63af4db..5ac0329 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-actions", - "version": "1.7.1", + "version": "1.8.0", "description": "", "main": "actions.js", "scripts": {