Skip to content

Commit 7fd77c1

Browse files
committed
fix mixTo an Function as Class #17
1 parent 4130cfe commit 7fd77c1

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

events.js

+16-5
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,24 @@ if (!keys) {
143143

144144
// Mix `Events` to object instance or Class function.
145145
Events.mixTo = function(receiver) {
146-
receiver = isFunction(receiver) ? receiver.prototype : receiver
147146
var proto = Events.prototype
148147

149-
var event = new Events
150-
for (var key in proto) {
151-
if (proto.hasOwnProperty(key)) {
152-
copyProto(key)
148+
if (isFunction(receiver)) {
149+
for (var key in proto) {
150+
if (proto.hasOwnProperty(key)) {
151+
receiver.prototype[key] = proto[key]
152+
}
153+
}
154+
Object.keys(proto).forEach(function(key) {
155+
receiver.prototype[key] = proto[key]
156+
})
157+
}
158+
else {
159+
var event = new Events
160+
for (var key in proto) {
161+
if (proto.hasOwnProperty(key)) {
162+
copyProto(key)
163+
}
153164
}
154165
}
155166

0 commit comments

Comments
 (0)