Permalink
Browse files

jQuery.migrateTrace property for stack traces. Close gh-10.

  • Loading branch information...
1 parent cd24938 commit 1a8947962b00054ef4359818ef1a23c5dc2f8d71 @silentroach silentroach committed with dmethvin Jan 16, 2013
Showing with 10 additions and 0 deletions.
  1. +2 −0 README.md
  2. +8 −0 src/migrate.js
View
2 README.md
@@ -63,6 +63,8 @@ This plugin adds three properties to the `jQuery` object that can be used progra
`jQuery.migrateMute`: Set this property to `true` to prevent console warnings from being generated in the debugging version. The `jQuery.migrateWarnings` array is still maintained when this property is set, which allows programmatic inspection without console output.
+`jQuery.migrateTrace`: Set this property to `false` if you want warnings but do not want traces to appear on the console.
+
`jQuery.migrateReset()`: This method clears the `jQuery.migrateWarnings` array and "forgets" the list of messages that have been seen already.
## Reporting problems
View
8 src/migrate.js
@@ -7,6 +7,11 @@ jQuery.migrateWarnings = [];
// Set to true to prevent console output; migrateWarnings still maintained
// jQuery.migrateMute = false;
+// Set to false to disable traces that appear with warnings
+if ( typeof jQuery.migrateTrace === "undefined" ) {
@Krinkle
Krinkle Jan 18, 2013

Per code conventions, strictly compare against the constant directly instead of typeof operation with string comparison.

+ jQuery.migrateTrace = true;
+}
+
// Forget any warnings we've already given; public
jQuery.migrateReset = function() {
warnedAbout = {};
@@ -19,6 +24,9 @@ function migrateWarn( msg) {
jQuery.migrateWarnings.push( msg );
if ( window.console && console.warn && !jQuery.migrateMute ) {
console.warn( "JQMIGRATE: " + msg );
+ if ( jQuery.migrateTrace && console.trace ) {
+ console.trace();
+ }
}
}
}

0 comments on commit 1a89479

Please sign in to comment.