component/emitter — pull request #27 by ilsken (2013-07-15 17:31:54+00:00)
Title: Use .hasOwnProperties to determine if the instance has a _callbacks collection

Currently there's a bug/unexpected behavior if you use any of the `Emitter` methods on a prototype and then try and use them on instances. What happens is because `.prototype.on` will create a `_callbacks` object on the prototype, all instances will now share the same `._callbacks` object which is not desirable behavior.

This patch simply checks .hasOwnProperty when calling emitter methods to make sure the instance has it's own callback collection

For example:

```javascript
function Custom() {
Emitter.call(this)
}

Custom.prototype.__proto__ = Emitter.prototype;

var calls = []
var a = new Custom()
a.on('foo', function(){
calls.push('a')
})
var b = new Custom()
b.on('foo', function(){
calls.push('b')
})

b.emit('foo')
console.log(calls) // will be ['proto', 'a', 'b'] instead of simply ['b']. Emitting an event on one instance now triggers listeners on all instances