File tree 3 files changed +16
-3
lines changed
3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,11 @@ MicroEvent.prototype = {
37
37
MicroEvent . mixin = function ( destObject ) {
38
38
var props = [ 'bind' , 'unbind' , 'trigger' ] ;
39
39
for ( var i = 0 ; i < props . length ; i ++ ) {
40
- destObject . prototype [ props [ i ] ] = MicroEvent . prototype [ props [ i ] ] ;
40
+ if ( typeof destObject === 'function' ) {
41
+ destObject . prototype [ props [ i ] ] = MicroEvent . prototype [ props [ i ] ] ;
42
+ } else {
43
+ destObject [ props [ i ] ] = MicroEvent . prototype [ props [ i ] ] ;
44
+ }
41
45
}
42
46
}
43
47
Original file line number Diff line number Diff line change @@ -40,7 +40,11 @@ MicroEvent.prototype = {
40
40
MicroEvent . mixin = function ( destObject ) {
41
41
var props = [ 'bind' , 'unbind' , 'trigger' ] ;
42
42
for ( var i = 0 ; i < props . length ; i ++ ) {
43
- destObject . prototype [ props [ i ] ] = MicroEvent . prototype [ props [ i ] ] ;
43
+ if ( typeof destObject === 'function' ) {
44
+ destObject . prototype [ props [ i ] ] = MicroEvent . prototype [ props [ i ] ] ;
45
+ } else {
46
+ destObject [ props [ i ] ] = MicroEvent . prototype [ props [ i ] ] ;
47
+ }
44
48
}
45
49
}
46
50
Original file line number Diff line number Diff line change @@ -9,4 +9,9 @@ console.log("You should see 'f got blerg yes' and nothing more:");
9
9
console . log ( "" )
10
10
11
11
f . trigger ( "blerg" , "yes" )
12
- b . trigger ( "blerg" , "no" )
12
+ b . trigger ( "blerg" , "no" )
13
+
14
+ c = { }
15
+ MicroEvent . mixin ( c )
16
+ c . bind ( 'foo' , function ( bar ) { console . log ( bar ) } )
17
+ c . trigger ( 'foo' , 'bar' )
You can’t perform that action at this time.
0 commit comments