Skip to content

Commit 2c3c878

Browse files
authored
Merge pull request mroderick#98 from mroderick/stop-using-jquery-error
Fix mroderick#94, prefer console.error instead, fallback to $.error when present
2 parents ff25277 + d6a8243 commit 2c3c878

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

wrappers/jquery/pubsub.js.post.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11

2+
function reportError(message) {
3+
if (typeof console !== 'undefined'){
4+
console.error(new Error(errorMessage));
5+
return;
6+
}
7+
8+
if ($.error) {
9+
$.error(errorMessage);
10+
}
11+
}
12+
213
if ( $.pubsub ){
3-
$.error( 'pubsub is already defined on jQuery, skipping integration of PubSubJS' );
14+
reportError('pubsub is already defined on jQuery, skipping integration of PubSubJS');
415
return false;
516
}
617

718
function pubsub( method ){
819
if ( PubSub.hasOwnProperty( method ) && typeof PubSub[ method ] === 'function' ){
920
return PubSub[ method ].apply( self, Array.prototype.slice.call( arguments, 1 ) );
10-
} else {
11-
$.error( 'Method ' + method + ' does not exist on jQuery.pubsub' );
1221
}
22+
23+
reportError('Method ' + method + ' does not exist on jQuery.pubsub');
1324
}
1425

1526
// export into jQuery

0 commit comments

Comments
 (0)