Skip to content

Commit

Permalink
fix mixTo an Function as Class #17
Browse files Browse the repository at this point in the history
  • Loading branch information
army8735 committed Jun 30, 2014
1 parent 4130cfe commit 7fd77c1
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions events.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,24 @@ if (!keys) {

// Mix `Events` to object instance or Class function.
Events.mixTo = function(receiver) {
receiver = isFunction(receiver) ? receiver.prototype : receiver
var proto = Events.prototype

var event = new Events
for (var key in proto) {
if (proto.hasOwnProperty(key)) {
copyProto(key)
if (isFunction(receiver)) {
for (var key in proto) {
if (proto.hasOwnProperty(key)) {
receiver.prototype[key] = proto[key]
}
}
Object.keys(proto).forEach(function(key) {
receiver.prototype[key] = proto[key]
})

This comment has been minimized.

Copy link
@afc163

afc163 Jan 9, 2015

Member

或者把这上面多余的三行删掉

}
else {
var event = new Events
for (var key in proto) {
if (proto.hasOwnProperty(key)) {
copyProto(key)
}
}
}

Expand Down

5 comments on commit 7fd77c1

@airyland
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

一个逻辑执行了两次?

@afc163
Copy link
Member

@afc163 afc163 commented on 7fd77c1 Jul 10, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

的确有问题,这个模块有必要好好review一下

@popomore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个要不要回滚啊

@popomore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你还留过言

@afc163
Copy link
Member

@afc163 afc163 commented on 7fd77c1 Jan 9, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

忘了啊,感觉各种混乱啊

Please sign in to comment.