azicchetti / jquerymobile-router

A router/controller for jquery mobile. Also adds support for client-side parameters in the hash part of the url. The routes handles regexp based routes. This plugin can be used alone or (better) with Backbone.js or Spine.js, because it's originally meant to replace their router with something integrated with jQM.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Debugging snippet gets in the way

mzedeler opened this issue · comments

This snippet:

var DEBUG = true;
function debug(err){
  if (DEBUG) {
    console.log(err);
    if (err.stack){ console.log(err.stack); }
  }
}

Seems to get more in the way than actually helping because Internet Explorer doesn't have a console object, so using debug in a try-catch block will just throw away what really went wrong and replace the actual error with something else.

I have two proposals to resolve this:

  • Remove this function and all references to it.
  • Expose an attribute that can contain a reference to a callback that receives debug calls.

I can implement both of the above, so just let me know which one and I'll do it.

I'd go for the second solution.
Adding a configuration option [defaulting to console.log, if
console.log() exists and nothing is provided by the user] to pass the
debug handler seems a safer way to handle this problem.

Ok. I'll get to work on it.

(Unless you want to, of course.)

I'm a little busy a.t.m., any help is greatly appreciated.
But don't worry, if you don't have time to write the patch, I think I can push the change (plus another small feature someone suggested via email) in the next few days.

Thank you for spotting the issue

I won't be able to fix it until some time this wednesday. I'll just check the issue here by then to see if you have a fix ready.