Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[PoC] Add jQuery.migrateWarnCallback feature #30

Closed
wants to merge 1 commit into from

2 participants

@kavu

The reason why I added this, is that with such callback I can notify some exception tracking service with deprecation messages. For example — notifying rollbar.com:

$.migrateWarnCallback = function(msg) {
  _rollbar.push({
    level: 'error',
    msg: "JQMIGRATE: " + msg
  });
};

Thanks!

@dmethvin
Owner

The facilities are already there to do this, using a timer. That has the advantage of sending the bulk of the messages in one shot, since many of them will happen on initialization. So after document ready just set a timer for, say, every 5 seconds and check whether new messages have been put into the warnings array.

@dmethvin dmethvin closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 13, 2013
  1. @kavu
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 0 deletions.
  1. +7 −0 src/migrate.js
View
7 src/migrate.js
@@ -4,6 +4,9 @@ var warnedAbout = {};
// List of warnings already given; public read only
jQuery.migrateWarnings = [];
+// Default migrateWarn callback is undefined
+jQuery.migrateWarnCallback = undefined;
+
// Set to true to prevent console output; migrateWarnings still maintained
// jQuery.migrateMute = false;
@@ -33,6 +36,10 @@ function migrateWarn( msg) {
console.trace();
}
}
+ // Call the callback passing the message
+ if ( !jQuery.migrateMute && typeof(jQuery.migrateWarnCallback) === "function" ) {
+ jQuery.migrateWarnCallback(msg);
+ }
}
}
Something went wrong with that request. Please try again.