Created
July 21, 2015 02:55
Quick hack to make Infusion work in a Web Worker
This file contains hidden or 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
diff --git a/third-party/infusion/js/Fluid.js b/third-party/infusion/js/Fluid.js | |
index 7913a4c..d132d1e 100644 | |
--- a/third-party/infusion/js/Fluid.js | |
+++ b/third-party/infusion/js/Fluid.js | |
@@ -24,7 +24,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt | |
*/ | |
// Declare dependencies | |
-/* global console, opera, YAHOO*/ | |
+/* global self, console, opera, YAHOO*/ | |
var fluid_2_0 = fluid_2_0 || {}; | |
var fluid = fluid || fluid_2_0; | |
@@ -42,7 +42,8 @@ var fluid = fluid || fluid_2_0; | |
fluid: fluid | |
}; | |
- fluid.global = fluid.global || window || {}; | |
+ var globalContext = typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : undefined; | |
+ fluid.global = fluid.global || globalContext || {}; | |
// A standard utility to schedule the invocation of a function after the current | |
// stack returns. On browsers this defaults to setTimeout(func, 1) but in | |
@@ -684,8 +685,8 @@ var fluid = fluid || fluid_2_0; | |
}); | |
return togo; | |
}; | |
- | |
- /** Converts an array consisting of a mixture of arrays and non-arrays into the concatenation of any inner arrays | |
+ | |
+ /** Converts an array consisting of a mixture of arrays and non-arrays into the concatenation of any inner arrays | |
* with the non-array elements | |
*/ | |
fluid.flatten = function (array) { | |
diff --git a/third-party/infusion/js/jquery.standalone.js b/third-party/infusion/js/jquery.standalone.js | |
index f49f344..c72931c 100644 | |
--- a/third-party/infusion/js/jquery.standalone.js | |
+++ b/third-party/infusion/js/jquery.standalone.js | |
@@ -17,7 +17,7 @@ | |
* Date: Thu May 12 15:04:36 2011 -0400 | |
*/ | |
-/* global jQuery:true */ | |
+/* global jQuery:true, self */ | |
/* exported jQuery */ | |
var fluid_2_0 = fluid_2_0 || {}; | |
@@ -30,10 +30,11 @@ var fluid = fluid || fluid_2_0; | |
var toString = Object.prototype.toString; | |
var hasOwn = Object.prototype.hasOwnProperty; | |
var indexOf = Array.prototype.indexOf; | |
+ var globalContext = typeof window !== "undefined" ? window : self; | |
// Map over jQuery in case of overwrite | |
- var _jQuery = window.jQuery; | |
+ var _jQuery = globalContext.jQuery; | |
// Map over the $ in case of overwrite | |
- var _$ = window.$; | |
+ var _$ = globalContext.$; | |
// Used for trimming whitespace | |
var trimLeft = /^\s+/, | |
trimRight = /\s+$/, | |
@@ -45,11 +46,11 @@ var fluid = fluid || fluid_2_0; | |
jquery: "1.6.1-fluidStandalone", | |
noConflict: function (deep) { | |
- if (window.$ === jQuery) { | |
- window.$ = _$; | |
+ if (globalContext.$ === jQuery) { | |
+ globalContext.$ = _$; | |
} | |
- if (deep && window.jQuery === jQuery) { | |
- window.jQuery = _jQuery; | |
+ if (deep && globalContext.jQuery === jQuery) { | |
+ globalContext.jQuery = _jQuery; | |
} | |
return jQuery; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment