Skip to content

Commit

Permalink
Tests: Simplify globals cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
markelog committed Apr 15, 2014
1 parent 7149726 commit a7c9fac
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions test/data/testrunner.js
Expand Up @@ -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 = {};
}
};
})();
Expand Down

0 comments on commit a7c9fac

Please sign in to comment.