Skip to content

Commit

Permalink
Make sure logging doesn't cause JS errors for browsers without console.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwheare committed Mar 14, 2009
1 parent 4fefe32 commit b3b1cb0
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ext/update_helper/update_helper.js
Expand Up @@ -61,6 +61,7 @@ var UpdateHelper = Class.create({
},

log: function(message, type) {
if (Object.isUndefined(console)) return;
if (type == 'error') console.error(message);
else if (type == 'warn') console.warn(message);
else console.log(message);
Expand Down

1 comment on commit b3b1cb0

@tobie
Copy link

@tobie tobie commented on b3b1cb0 Mar 14, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wouldn’t work, actually. you’d need to do:

if (Object.isUndefined(window.console)) return;

or:

if (typeof console === 'undefined') return;

Also, it might be worth returning earlier than that (at runtime, form example).

Thanks for your input.

Please sign in to comment.