Permalink
Browse files

updated blue-ridge initialization

  • Loading branch information...
1 parent 7be3026 commit d755e13e7a21ab4d4b964352e10c7f5a4009d224 @bartaz committed Aug 12, 2009
Showing with 44 additions and 24 deletions.
  1. +41 −20 lib/blue-ridge.js
  2. +3 −4 lib/test_runner.js
View
@@ -1,7 +1,7 @@
var BLUE_RIDGE_LIB_PREFIX = BLUE_RIDGE_LIB_PREFIX || "../../vendor/plugins/blue-ridge/lib/";
var BlueRidge = {
- require: function(url, options){
+ require: function(url, callback){
// add a '../' prefix to all JavaScript paths because we expect to be ran from one of:
// * test/javascript/fixtures
// * specs/javascripts/fixtures
@@ -12,13 +12,20 @@ var BlueRidge = {
var script = document.createElement("script");
script.src = url;
- options = options || {};
-
- if(options['onload']) {
- // Attach handlers for all browsers
- script.onload = script.onreadystatechange = options['onload'];
- }
-
+ if(callback){
+ var done = false;
+ // Attach handlers for all browsers
+ script.onload = script.onreadystatechange = function(){
+ if (!done && (!this.readyState ||
+ this.readyState == "loaded" || this.readyState == "complete") ) {
+ done = true;
+ callback.call();
+ // Handle memory leak in IE
+ script.onload = script.onreadystatechange = null;
+ head.removeChild( script );
+ }
+ };
+ };
head.appendChild(script);
},
@@ -35,16 +42,30 @@ var BlueRidge = {
var require = require || BlueRidge.require;
var debug = debug || BlueRidge.debug;
-require(BLUE_RIDGE_LIB_PREFIX + "jquery-1.3.2.js");
-require(BLUE_RIDGE_LIB_PREFIX + "jquery.fn.js");
-require(BLUE_RIDGE_LIB_PREFIX + "jquery.print.js");
-require(BLUE_RIDGE_LIB_PREFIX + "screw.builder.js");
-require(BLUE_RIDGE_LIB_PREFIX + "screw.matchers.js");
-require(BLUE_RIDGE_LIB_PREFIX + "screw.events.js");
-require(BLUE_RIDGE_LIB_PREFIX + "screw.behaviors.js");
-require(BLUE_RIDGE_LIB_PREFIX + "smoke.core.js");
-require(BLUE_RIDGE_LIB_PREFIX + "smoke.mock.js");
-require(BLUE_RIDGE_LIB_PREFIX + "smoke.stub.js");
-require(BLUE_RIDGE_LIB_PREFIX + "screw.mocking.js");
+// all required js libs are now nested to load properly
+
+require(BLUE_RIDGE_LIB_PREFIX + "jquery-1.3.2.js", function(){
+ require(BLUE_RIDGE_LIB_PREFIX + "jquery.fn.js", function(){
+ require(BLUE_RIDGE_LIB_PREFIX + "jquery.print.js", function(){
+ require(BLUE_RIDGE_LIB_PREFIX + "screw.builder.js", function(){
+ require(BLUE_RIDGE_LIB_PREFIX + "screw.matchers.js", function(){
+ require(BLUE_RIDGE_LIB_PREFIX + "screw.events.js", function(){
+ require(BLUE_RIDGE_LIB_PREFIX + "screw.behaviors.js", function(){
+ require(BLUE_RIDGE_LIB_PREFIX + "smoke.core.js", function(){
+ require(BLUE_RIDGE_LIB_PREFIX + "smoke.mock.js", function(){
+ require(BLUE_RIDGE_LIB_PREFIX + "smoke.stub.js", function(){
+ require(BLUE_RIDGE_LIB_PREFIX + "screw.mocking.js",function(){
+ require(BlueRidge.deriveSpecNameFromCurrentFile());
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+});
+
-require(BlueRidge.deriveSpecNameFromCurrentFile());
View
@@ -6,12 +6,11 @@ if(arguments.length == 0) {
var PLUGIN_PREFIX = environment["blue.ridge.prefix"] || "../../vendor/plugins/blue-ridge";
var BlueRidge = {
- require: function(file, options){
+ require: function(file, callback){
load(file);
- options = options || {};
- if(options['onload']) {
- options['onload'].call();
+ if(callback) {
+ callback.call();
}
},

2 comments on commit d755e13

Does this fix the problem with Screw.Unit never running in Safari 4?

Owner

bartaz replied Sep 10, 2009

It seems to fix problems I've had with webkit browsers (Chrome, Safari).

Please sign in to comment.