From 72909c35b2de1f5cdd131f6ffe8cc4f908965f71 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 4 Aug 2022 16:48:28 +0300 Subject: [PATCH] now proto event handlers are not triggered... Signed-off-by: Alex A. Naanou --- event.js | 15 +++++++++++---- package.json | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/event.js b/event.js index 83a7ebd..b85e1c4 100644 --- a/event.js +++ b/event.js @@ -132,9 +132,12 @@ object.Constructor('Eventful', { return this }, unbind: function(context, handler){ var handlers = - (this.handlerLocation == 'method' ? + this.handlerLocation == 'method' ? method.__event_handlers__ - : (context.__event_handlers__ || {})[this.name]) || [] + //: (context.__event_handlers__ || {})[this.name]) || [] + : context.hasOwnProperty('__event_handlers__') ? + (context.__event_handlers__ || {})[this.name] || [] + : [] handlers.splice(0, handlers.length, ...handlers.filter(function(h){ return h !== handler @@ -150,7 +153,10 @@ object.Constructor('Eventful', { // context (default)... // NOTE: these are allways called... handlers = handlers - .concat((context.__event_handlers__ || {})[this.name] || []) + //.concat((context.__event_handlers__ || {})[this.name] || []) + .concat(context.hasOwnProperty('__event_handlers__') ? + (context.__event_handlers__ || {})[this.name] || [] + : []) // NOTE: this will stop event handling if one of the handlers // explicitly returns false... @@ -334,7 +340,8 @@ module.EventHandlerMixin = object.Mixin('EventHandlerMixin', { evt in this ? // XXX add a better check... this[evt](module.TRIGGER, ...args) - : this.__event_handlers__ + //: this.__event_handlers__ + : this.hasOwnProperty('__event_handlers__') && (this.__event_handlers__[evt] || []) .forEach(function(h){ h(evt, ...args) }) return this }, diff --git a/package.json b/package.json index 6429a42..cf33f49 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-types", - "version": "6.16.2", + "version": "6.16.3", "description": "Generic JavaScript types and type extensions...", "main": "main.js", "scripts": {