Skip to content

Commit 8f49d0b

Browse files
committed
Define self and window global objects in the combined JS code so that:
* components making use of `window` can actually do it without the trick found in the `components.js` file of the dummy test app * components/files packaged as CommonJS modules by browserify (using browserify-rails for instance) can successfully use `global` For this second point, this fix is necessary because of the self-calling function browserify uses to wrap code that uses the `global` variable: ```ruby (function (global){ global.MyComponent = React.createClass({ ... }); }).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) ``` If `window` was used instead of `global`, it would still need the fix or the workaround found in the tests' dummy app as mentioned.
1 parent b4051e1 commit 8f49d0b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/react/renderer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def self.render(component, args={})
2222

2323
def self.setup_combined_js
2424
<<-CODE
25-
var global = global || this;
25+
var global = global || this, self = self || this, window = window || this;
2626
2727
var console = global.console || {};
2828
['error', 'log', 'info', 'warn'].forEach(function (fn) {

0 commit comments

Comments
 (0)