ngraph.events
Advanced tools
Comparing version 0.0.2 to 0.0.3
20
index.js
@@ -17,3 +17,3 @@ module.exports = function(subject) { | ||
// { 'eventName' => [{callback: function, ctx: object}] } | ||
var registeredEvents = {}; | ||
var registeredEvents = Object.create(null); | ||
@@ -25,6 +25,7 @@ return { | ||
} | ||
if (!registeredEvents.hasOwnProperty(eventName)) { | ||
registeredEvents[eventName] = []; | ||
var handlers = registeredEvents[eventName]; | ||
if (!handlers) { | ||
handlers = registeredEvents[eventName] = []; | ||
} | ||
registeredEvents[eventName].push({callback: callback, ctx: ctx}); | ||
handlers.push({callback: callback, ctx: ctx}); | ||
@@ -38,7 +39,7 @@ return subject; | ||
// Killing old events storage should be enough in this case: | ||
registeredEvents = {}; | ||
registeredEvents = Object.create(null); | ||
return subject; | ||
} | ||
if (registeredEvents.hasOwnProperty(eventName)) { | ||
if (registeredEvents[eventName]) { | ||
var deleteAllCallbacksForEvent = (typeof callback !== 'function'); | ||
@@ -61,8 +62,7 @@ if (deleteAllCallbacksForEvent) { | ||
fire: function (eventName) { | ||
var noEventsToFire = !registeredEvents.hasOwnProperty(eventName); | ||
if (noEventsToFire) { | ||
return subject; | ||
var callbacks = registeredEvents[eventName]; | ||
if (!callbacks) { | ||
return subject; | ||
} | ||
var callbacks = registeredEvents[eventName]; | ||
var fireArguments; | ||
@@ -69,0 +69,0 @@ if (arguments.length > 1) { |
{ | ||
"name": "ngraph.events", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Basic events supoort for ngraph.js ", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9969