Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Commit bf6fa88

Browse files
committed
Replace all the references to window as Opal.global
1 parent cc83b1a commit bf6fa88

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

lib/hyper-react.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

33
if RUBY_ENGINE == 'opal'
4-
if `window.React === undefined || window.React.version === undefined`
4+
if `Opal.global.React === undefined || Opal.global.React.version === undefined`
55
raise [
66
"No React.js Available",
77
"",

lib/react/api.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def self.eval_native_react_component(name)
2727
(`!!#{component}.prototype.isReactComponent` ||
2828
`!!#{component}.prototype.render`)
2929
is_functional_component = `typeof #{component} === "function"`
30-
is_not_using_react_v13 = `!window.React.version.match(/0\.13/)`
30+
is_not_using_react_v13 = `!Opal.global.React.version.match(/0\.13/)`
3131
unless is_component_class || (is_not_using_react_v13 && is_functional_component)
3232
raise 'does not appear to be a native react component'
3333
end

lib/react/component/class_methods.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ def static_call_backs
181181
def export_component(opts = {})
182182
export_name = (opts[:as] || name).split('::')
183183
first_name = export_name.first
184-
Native(`window`)[first_name] = add_item_to_tree(
185-
Native(`window`)[first_name],
184+
Native(`Opal.global`)[first_name] = add_item_to_tree(
185+
Native(`Opal.global`)[first_name],
186186
[React::API.create_native_react_class(self)] + export_name[1..-1].reverse
187187
).to_n
188188
end

lib/react/state.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def remove # call after component is unmounted
159159
end
160160

161161
def set_state_context_to(observer, rendering = nil) # wrap all execution that may set or get states in a block so we know which observer is executing
162-
if `typeof window.reactive_ruby_timing !== 'undefined'`
162+
if `typeof Opal.global.reactive_ruby_timing !== 'undefined'`
163163
@nesting_level = (@nesting_level || 0) + 1
164164
start_time = Time.now.to_f
165165
observer_name = (observer.class.respond_to?(:name) ? observer.class.name : observer.to_s) rescue "object:#{observer.object_id}"
@@ -172,7 +172,7 @@ def set_state_context_to(observer, rendering = nil) # wrap all execution that ma
172172
ensure
173173
@current_observer = saved_current_observer
174174
@rendering_level -= 1 if rendering
175-
@nesting_level = [0, @nesting_level - 1].max if `typeof window.reactive_ruby_timing !== 'undefined'`
175+
@nesting_level = [0, @nesting_level - 1].max if `typeof Opal.global.reactive_ruby_timing !== 'undefined'`
176176
return_value
177177
end
178178

lib/reactive-ruby/isomorphic_helpers.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def self.on_opal_client?
5353
end
5454
else
5555
def self.on_opal_server?
56-
`typeof window.document === 'undefined'`
56+
`typeof Opal.global.document === 'undefined'`
5757
end
5858

5959
def self.on_opal_client?
@@ -143,7 +143,7 @@ def when_on_client(&block)
143143
def send_to_server(*args)
144144
if IsomorphicHelpers.on_opal_server?
145145
args_as_json = args.to_json
146-
@result = [JSON.parse(`window.ServerSideIsomorphicMethods[#{@name}](#{args_as_json})`)]
146+
@result = [JSON.parse(`Opal.global.ServerSideIsomorphicMethods[#{@name}](#{args_as_json})`)]
147147
end
148148
end
149149

0 commit comments

Comments
 (0)