Skip to content

Instantly share code, notes, and snippets.

@bcardarella
Created October 18, 2014 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcardarella/cf5c14311af42e38d932 to your computer and use it in GitHub Desktop.
Save bcardarella/cf5c14311af42e38d932 to your computer and use it in GitHub Desktop.
requirejs.rollback = function() {
for(var entry in this.previousEntries) {
if (this.previousEntries[entry]) {
registry[entry] = this.previousEntries[entry];
} else {
delete registry[entry];
}
}
};
requirejs.define = function(entry, deps, callback) {
if (this.previousEntries[entry]) {
throw 'cannot define twice';
} else {
this.previousEntries[entry] = registry[entry];
registry[entry] = { deps: deps, callback: callback };
}
};
module('validator class lookup order', {
setup: function() {
requirejs.previousEntries = {};
},
teardown: function() {
requirejs.rollback();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment