Permalink
Browse files

fix namespace removal bug where removing sub namespace

  • Loading branch information...
1 parent bf05697 commit 9b6703f463e9b932ea887b2a06bbec0c5425e48c @fat committed Aug 18, 2011
Showing with 9 additions and 4 deletions.
  1. +1 −1 package.json
  2. +8 −3 src/bean.js
View
@@ -1,7 +1,7 @@
{
"name": "bean",
"description": "an events api for javascript",
- "version": "0.2.4",
+ "version": "0.2.5",
"homepage": "https://github.com/fat/bean",
"authors": ["Jacob Thornton <@fat>"],
"repository": {
View
@@ -90,16 +90,21 @@
}
names = orgType.replace(namespace, '');
uids = names ? names.split('.') : [handler.__uid];
- for (i = uids.length; i--;) {
- uid = uids[i];
+
+ function destroyHandler(uid) {
handler = events[type][uid];
+ if (!handler) return;
delete events[type][uid];
if (element[eventSupport]) {
type = customEvents[type] ? customEvents[type].base : type;
var isNative = W3C_MODEL || nativeEvents[type];
listener(element, isNative ? type : 'propertychange', handler, false, !isNative && type);
}
}
+
+ destroyHandler(names) //get combos
+ for (i = uids.length; i--; destroyHandler(uids[i])); //get singles
+
return element;
},
@@ -149,7 +154,7 @@
for (k in attached) {
if (attached.hasOwnProperty(k)) {
for (i in attached[k]) {
- attached[k].hasOwnProperty(i) && i === names && rm(element, [k, names].join('.'));
+ attached[k].hasOwnProperty(i) && new RegExp('^' + names + '(\\..*)?$').test(i) && rm(element, [k, i].join('.'));
}
}
}

0 comments on commit 9b6703f

Please sign in to comment.