File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -207,7 +207,18 @@ https://github.com/mroderick/PubSubJS
207
207
* PubSub.unsubscribe('mytopic');
208
208
*/
209
209
PubSub . unsubscribe = function ( value ) {
210
- var isTopic = typeof value === 'string' && messages . hasOwnProperty ( value ) ,
210
+ var descendantTopicExists = function ( topic ) {
211
+ var m ;
212
+ for ( m in messages ) {
213
+ if ( messages . hasOwnProperty ( m ) && m . indexOf ( topic ) === 0 ) {
214
+ // a descendant of the topic exists:
215
+ return true ;
216
+ }
217
+ }
218
+
219
+ return false ;
220
+ } ,
221
+ isTopic = typeof value === 'string' && ( messages . hasOwnProperty ( value ) || descendantTopicExists ( value ) ) ,
211
222
isToken = ! isTopic && typeof value === 'string' ,
212
223
isFunction = typeof value === 'function' ,
213
224
result = false ,
You can’t perform that action at this time.
0 commit comments