Skip to content
Permalink
Browse files

Tests: Simplify globals cleanup

  • Loading branch information
markelog committed Jan 27, 2014
1 parent 7149726 commit a7c9facc357b4d2d98844cda4c26bb2e560c0cc8
Showing with 9 additions and 10 deletions.
  1. +9 −10 test/data/testrunner.js
@@ -172,23 +172,22 @@ reset = function () {
QUnit.testDone(reset);

// Register globals for cleanup and the cleanup code itself
// Explanation at http://perfectionkills.com/understanding-delete/#ie_bugs
window.Globals = (function() {
var globals = {};

return {
register: function( name ) {
globals[ name ] = true;
supportjQuery.globalEval( "var " + name + " = undefined;" );
window[ name ] = globals[ name ] = true;
},

cleanup: function() {
var name,
current = globals;
globals = {};
for ( name in current ) {
supportjQuery.globalEval( "try { " +
"delete " + ( supportjQuery.support.deleteExpando ? "window['" + name + "']" : name ) +
"; } catch( x ) {}" );
var name;

for ( name in globals ) {
delete window[ name ];
}

globals = {};
}
};
})();

0 comments on commit a7c9fac

Please sign in to comment.
You can’t perform that action at this time.