This repository has been archived by the owner. It is now read-only.

events: Support prototype property name as an event type #4366

Closed
wants to merge 1 commit into
from
Commits on Dec 5, 2012
  1. events: Support prototype property name as an event type

    tricknotes committed Dec 5, 2012
    The prototype name (such as '__proto__') as an event type
    does not work as my expectation.
    
    ```
    > var events = require('events')
    > var e = new events.EventEmitter();
    > e.on('__proto__', function() {});
    > e.emit('__proto__');
    TypeError: Object #<Object> has no method 'apply'
        at EventEmitter.emit (events.js:126:20)
        at repl:1:3
        at REPLServer.self.eval (repl.js:109:21)
        at rli.on.self.bufferedCmd (repl.js:258:20)
        at REPLServer.self.eval (repl.js:116:5)
        at Interface.<anonymous> (repl.js:248:12)
        at Interface.EventEmitter.emit (events.js:96:17)
        at Interface._onLine (readline.js:200:10)
        at Interface._line (readline.js:518:8)
        at Interface._ttyWrite (readline.js:736:14)
    ```
    
    To support these, use `Object.create(null)` instead of `{}`.