Skip to content

Commit

Permalink
Fix mroderick#94, prefer console.error instead, fallback to $.error w…
Browse files Browse the repository at this point in the history
…hen present
  • Loading branch information
mroderick committed Oct 18, 2016
1 parent ff25277 commit d6a8243
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions wrappers/jquery/pubsub.js.post.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@

function reportError(message) {
if (typeof console !== 'undefined'){
console.error(new Error(errorMessage));
return;
}

if ($.error) {
$.error(errorMessage);
}
}

if ( $.pubsub ){
$.error( 'pubsub is already defined on jQuery, skipping integration of PubSubJS' );
reportError('pubsub is already defined on jQuery, skipping integration of PubSubJS');
return false;
}

function pubsub( method ){
if ( PubSub.hasOwnProperty( method ) && typeof PubSub[ method ] === 'function' ){
return PubSub[ method ].apply( self, Array.prototype.slice.call( arguments, 1 ) );
} else {
$.error( 'Method ' + method + ' does not exist on jQuery.pubsub' );
}

reportError('Method ' + method + ' does not exist on jQuery.pubsub');
}

// export into jQuery
Expand Down

0 comments on commit d6a8243

Please sign in to comment.