mirror of
https://github.com/flynx/actions.js.git
synced 2025-10-28 18:00:11 +00:00
revised how handlers are collected + tweaks and fixes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
db30c569ba
commit
2b9c003d65
26
actions.js
26
actions.js
@ -1252,14 +1252,13 @@ module.MetaActions = {
|
|||||||
|
|
||||||
// get the handlers...
|
// get the handlers...
|
||||||
var handlers = []
|
var handlers = []
|
||||||
|
var actions = []
|
||||||
var cur = this
|
var cur = this
|
||||||
while(cur.__proto__ != null){
|
while(cur != null){
|
||||||
// get action "event" handlers...
|
// get action "event" handlers...
|
||||||
if(cur.hasOwnProperty('__action_handlers')
|
if(cur.hasOwnProperty('__action_handlers')
|
||||||
&& name in cur.__action_handlers){
|
&& name in cur.__action_handlers){
|
||||||
handlers.splice.apply(handlers,
|
handlers.push(cur.__action_handlers[name]) }
|
||||||
[handlers.length, 0]
|
|
||||||
.concat(cur.__action_handlers[name])) }
|
|
||||||
|
|
||||||
// get the overloading action...
|
// get the overloading action...
|
||||||
// NOTE: this will get all the handlers including the root
|
// NOTE: this will get all the handlers including the root
|
||||||
@ -1269,15 +1268,21 @@ module.MetaActions = {
|
|||||||
if(cur.hasOwnProperty(name)){
|
if(cur.hasOwnProperty(name)){
|
||||||
// action -> collect...
|
// action -> collect...
|
||||||
if(cur[name] instanceof Action){
|
if(cur[name] instanceof Action){
|
||||||
handlers.push(cur[name].func)
|
actions.push(cur[name].func)
|
||||||
|
|
||||||
// function -> terminate chain...
|
// function -> terminate chain...
|
||||||
} else if(cur[name] instanceof Function){
|
} else if(cur[name] instanceof Function){
|
||||||
handlers.push(cur[name])
|
actions.push(cur[name])
|
||||||
break } }
|
break } }
|
||||||
|
|
||||||
cur = cur.__proto__ }
|
cur = cur.__proto__ }
|
||||||
|
|
||||||
|
// NOTE: we call all the handlers before the actions... (???)
|
||||||
|
handlers = [
|
||||||
|
...handlers.flat(),
|
||||||
|
...actions,
|
||||||
|
]
|
||||||
|
|
||||||
// handler cache...
|
// handler cache...
|
||||||
// XXX EXPERIMENTAL (handler cache)...
|
// XXX EXPERIMENTAL (handler cache)...
|
||||||
if(cache){
|
if(cache){
|
||||||
@ -1370,7 +1375,7 @@ module.MetaActions = {
|
|||||||
// NOTE: 'post' mode is the default.
|
// NOTE: 'post' mode is the default.
|
||||||
//
|
//
|
||||||
// XXX should we have multiple tags per handler???
|
// XXX should we have multiple tags per handler???
|
||||||
__action_handlers: null,
|
//__action_handlers: null,
|
||||||
on: function(actions, b, c){
|
on: function(actions, b, c){
|
||||||
var that = this
|
var that = this
|
||||||
var _handler = arguments.length == 3 ? c : b
|
var _handler = arguments.length == 3 ? c : b
|
||||||
@ -1712,13 +1717,14 @@ module.MetaActions = {
|
|||||||
// otherwise only mixin local actions...
|
// otherwise only mixin local actions...
|
||||||
// NOTE: this will override existing own attributes.
|
// NOTE: this will override existing own attributes.
|
||||||
//
|
//
|
||||||
|
// XXX should this also mixin .__action_handlers???
|
||||||
// XXX should we include functions by default????
|
// XXX should we include functions by default????
|
||||||
// XXX should .source_tag be set here or in Actions(..)???
|
// XXX should .source_tag be set here or in Actions(..)???
|
||||||
inlineMixin: function(from, options){
|
inlineMixin: function(from, options){
|
||||||
// defaults...
|
// defaults...
|
||||||
options = options || {}
|
options = options || {}
|
||||||
var descriptors = options.descriptors || true
|
var descriptors = options.descriptors == null ? true : false
|
||||||
var all_attr_types = options.all_attr_types || false
|
var all_attr_types = options.all_attr_types == null ? false : true
|
||||||
var source_tag = options.source_tag
|
var source_tag = options.source_tag
|
||||||
|
|
||||||
resetHandlerCache = (this.resetHandlerCache || MetaActions.resetHandlerCache)
|
resetHandlerCache = (this.resetHandlerCache || MetaActions.resetHandlerCache)
|
||||||
@ -1891,7 +1897,7 @@ module.MetaActions = {
|
|||||||
//
|
//
|
||||||
// XXX is this correct???
|
// XXX is this correct???
|
||||||
// XXX should this be an action???
|
// XXX should this be an action???
|
||||||
// XXX should this handle .__action_handlers ???
|
// XXX should this handle .__handler_cache ???
|
||||||
clone: function(full){
|
clone: function(full){
|
||||||
var o = Object.create(this)
|
var o = Object.create(this)
|
||||||
if(this.config){
|
if(this.config){
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ig-actions",
|
"name": "ig-actions",
|
||||||
"version": "3.24.25",
|
"version": "3.24.26",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "actions.js",
|
"main": "actions.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user