File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 */
55export default function mitt ( all ) {
66 // Arrays of event handlers, keyed by type
7- all = all || { } ;
7+ all = all || Object . create ( null ) ;
88
99 // Get or create a named handler list
1010 function list ( type ) {
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ describe('mitt', () => {
1414 let events , inst ;
1515
1616 beforeEach ( ( ) => {
17- events = { } ;
17+ events = Object . create ( null ) ;
1818 inst = mitt ( events ) ;
1919 } ) ;
2020
@@ -32,6 +32,13 @@ describe('mitt', () => {
3232 expect ( events ) . to . have . property ( 'foo' ) . that . deep . equals ( [ foo ] ) ;
3333 } ) ;
3434
35+ it ( 'should register handlers for any type strings' , ( ) => {
36+ let foo = ( ) => { } ;
37+ inst . on ( 'constructor' , foo ) ;
38+
39+ expect ( events ) . to . have . property ( 'constructor' ) . that . deep . equals ( [ foo ] ) ;
40+ } ) ;
41+
3542 it ( 'should append handler for existing type' , ( ) => {
3643 let foo = ( ) => { } ;
3744 let bar = ( ) => { } ;
You can’t perform that action at this time.
0 commit comments