Skip to content
This repository
Browse code

fix namespace removal bug where removing sub namespace

  • Loading branch information...
commit 9b6703f463e9b932ea887b2a06bbec0c5425e48c 1 parent bf05697
Jacob authored
2  package.json
... ...
@@ -1,7 +1,7 @@
1 1
 {
2 2
   "name": "bean",
3 3
   "description": "an events api for javascript",
4  
-  "version": "0.2.4",
  4
+  "version": "0.2.5",
5 5
   "homepage": "https://github.com/fat/bean",
6 6
   "authors": ["Jacob Thornton <@fat>"],
7 7
   "repository": {
11  src/bean.js
@@ -90,9 +90,10 @@
90 90
     }
91 91
     names = orgType.replace(namespace, '');
92 92
     uids = names ? names.split('.') : [handler.__uid];
93  
-    for (i = uids.length; i--;) {
94  
-      uid = uids[i];
  93
+
  94
+    function destroyHandler(uid) {
95 95
       handler = events[type][uid];
  96
+      if (!handler) return;
96 97
       delete events[type][uid];
97 98
       if (element[eventSupport]) {
98 99
         type = customEvents[type] ? customEvents[type].base : type;
@@ -100,6 +101,10 @@
100 101
         listener(element, isNative ? type : 'propertychange', handler, false, !isNative && type);
101 102
       }
102 103
     }
  104
+
  105
+    destroyHandler(names) //get combos
  106
+    for (i = uids.length; i--; destroyHandler(uids[i])); //get singles
  107
+
103 108
     return element;
104 109
   },
105 110
 
@@ -149,7 +154,7 @@
149 154
         for (k in attached) {
150 155
           if (attached.hasOwnProperty(k)) {
151 156
             for (i in attached[k]) {
152  
-              attached[k].hasOwnProperty(i) && i === names && rm(element, [k, names].join('.'));
  157
+              attached[k].hasOwnProperty(i) && new RegExp('^' + names + '(\\..*)?$').test(i) && rm(element, [k, i].join('.'));
153 158
             }
154 159
           }
155 160
         }

0 notes on commit 9b6703f

Please sign in to comment.
Something went wrong with that request. Please try again.