* @return {mw.hook}
*/
return function ( name ) {
- var list = lists[name] || ( lists[name] = $.Callbacks( 'memory' ) );
+ var list = hasOwn.call( lists, name ) ?
+ lists[name] :
+ lists[name] = $.Callbacks( 'memory' );
return {
/**
} );
- QUnit.test( 'mw.hook', 12, function ( assert ) {
+ QUnit.test( 'mw.hook', 13, function ( assert ) {
var hook, add, fire, chars, callback;
mw.hook( 'test.hook.unfired' ).add( function () {
} );
mw.hook( 'test.hook.basic' ).fire();
+ mw.hook( 'hasOwnProperty' ).add( function () {
+ assert.ok( true, 'hook with name of predefined method' );
+ } );
+ mw.hook( 'hasOwnProperty' ).fire();
+
mw.hook( 'test.hook.data' ).add( function ( data1, data2 ) {
assert.equal( data1, 'example', 'Fire with data (string param)' );
assert.deepEqual( data2, ['two'], 'Fire with data (array param)' );