Skip to content

Commit

Permalink
Merge pull request #159 from davej/patch-1
Browse files Browse the repository at this point in the history
Fix for undefined `this` in event handlers
  • Loading branch information
LeaVerou committed Jan 27, 2016
2 parents b894098 + 21e4f27 commit 2bc1cdf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bliss._.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ if (self.EventTarget && "addEventListener" in EventTarget.prototype) {
notEqual = function() { return !equal.apply(this, arguments); };

EventTarget.prototype.addEventListener = function(type, callback, capture) {
if (this[_] && callback) {
if (this && this[_] && callback) {
var listeners = this[_].bliss.listeners = this[_].bliss.listeners || {};

listeners[type] = listeners[type] || [];
Expand All @@ -77,7 +77,7 @@ if (self.EventTarget && "addEventListener" in EventTarget.prototype) {
};

EventTarget.prototype.removeEventListener = function(type, callback, capture) {
if (this[_] && callback) {
if (this && this[_] && callback) {
var listeners = this[_].bliss.listeners = this[_].bliss.listeners || {};

if (listeners[type]) {
Expand All @@ -93,4 +93,4 @@ if (self.EventTarget && "addEventListener" in EventTarget.prototype) {
self.$ = self.$ || $;
self.$$ = self.$$ || $.$;

})(Bliss);
})(Bliss);

0 comments on commit 2bc1cdf

Please sign in to comment.