From a59bd98abf4ac0bbec8893376b735db58404791b Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 2 Jul 2017 20:25:40 +0300 Subject: [PATCH] updated mixin docs and added .mixinAfter(..)... Signed-off-by: Alex A. Naanou --- actions.js | 18 ++++++++++++++++-- package.json | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/actions.js b/actions.js index 72e7894..159bb82 100755 --- a/actions.js +++ b/actions.js @@ -1284,6 +1284,9 @@ module.MetaActions = { // in the inheritance chain... // mixin: function(from, options){ + options = options || {} + options.source_tag = options.source_tag || from.__mixin_tag + var proto = Object.create(this.__proto__) // mixinto an empty object @@ -1302,6 +1305,16 @@ module.MetaActions = { return this }, + // Mixin from after target in the mro... + // + // NOTE: target must be .getMixin(..) compatible... + mixinAfter: function(target, from, options){ + this + .getMixin(target) + .mixin(from, options) + return this + }, + // Mixin a set of local actions into an object... // // XXX this will not work on non-actions... @@ -1309,7 +1322,6 @@ module.MetaActions = { return this.mixin.call(to, this, options) }, - // Remove mixed in actions from this... // // NOTE: this will only remove local actions, inherited actions will @@ -1365,14 +1377,16 @@ module.MetaActions = { // NOTE: this will remove only the first occurance of a mixin. mixout: function(from){ var o = this.getMixin(from, true) + var target = null // pop the mixin off the chain... if(o != null){ + target = o.__proto__ o.__proto__ = o.__proto__.__proto__ this.resetHandlerCache() } - return this + return target }, // Remove a set of local mixed in actions from object... diff --git a/package.json b/package.json index 178419b..8ffa06a 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-actions", - "version": "3.2.4", + "version": "3.2.5", "description": "", "main": "actions.js", "scripts": {