Skip to content

Commit

Permalink
merge latest master
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Nov 4, 2011
1 parent dfb4fed commit ddb95ef
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "bean",
"description": "an events api for javascript",
"version": "0.2.9",
"version": "0.3.0",
"homepage": "https://github.com/fat/bean",
"authors": ["Jacob Thornton <@fat>"],
"repository": {
Expand Down
27 changes: 24 additions & 3 deletions src/bean.js
Expand Up @@ -94,10 +94,12 @@
},

removeListener = function (element, orgType, handler) {
var uid, names, uids, i, events = retrieveEvents(element), type = orgType.replace(stripName, '');
var uid = element.__uid, names, uids, i, events = retrieveEvents(element), type = orgType.replace(stripName, '');

if (!events || !events[type]) {
return element;
}

handler && handler.__one && (handler = handler.__one)
names = orgType.replace(namespace, '');
uids = names ? names.split('.') : [handler.__uid];
Expand All @@ -118,6 +120,15 @@
destroyHandler(names); //get combos
for (i = uids.length; i--; destroyHandler(uids[i])) {} //get singles

if (isEmpty(events[type])) {
delete events[type];
}

if (isEmpty(registry[uid])) {
delete registry[uid];
delete collected[uid];
}

return element;
},

Expand Down Expand Up @@ -183,7 +194,9 @@
if (attached.hasOwnProperty(k)) {
for (i in attached[k]) {
for (m = names.length; m--;) {
attached[k].hasOwnProperty(i) && new RegExp('^' + names[m] + '::\\d*(\\..*)?$').test(i) && rm(element, [k, i].join('.'));
attached[k].hasOwnProperty(i) &&
new RegExp('^' + names[m] + '::\\d*(\\..*)?$').test(i) &&
rm(element, [k, i].join('.'));
}
}
}
Expand Down Expand Up @@ -280,7 +293,14 @@
}
}
return result;
};
},

isEmpty = function (obj) {
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) return false;
}
return true;
}

fixEvent.preventDefault = function (e) {
return function () {
Expand Down Expand Up @@ -353,4 +373,5 @@
};

return bean;

});

0 comments on commit ddb95ef

Please sign in to comment.