Created
October 4, 2011 23:15
-
-
Save danielericlee/1263127 to your computer and use it in GitHub Desktop.
Simple Dojo Widget Leak Detection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Query the registry | |
my_widgets = []; | |
dijit.registry.forEach(function(widget){ | |
my_widgets.push(widget.id); | |
}); | |
console.log("Widgets Captured (" + dijit.registry.length + ") in total)"); | |
// Query it again, produce a Diff | |
var leakyWidgets = []; | |
dijit.registry.forEach(function(widget){ | |
if(dojo.indexOf(my_widgets, widget.id) === -1) { | |
leakyWidgets.push(widget.declaredClass); | |
} | |
}); | |
console.log(leakyWidgets.length + " potential leaks found"); | |
console.log("Potential Leaks: " + leakyWidgets.join(", ")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment