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

Commit ea87551

Browse files
catmandozetachang
authored andcommitted
opal 10.x compatibility fixes
1 parent 25b8231 commit ea87551

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

lib/react/native_library.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def const_missing(const_name)
4646
end
4747

4848
def method_missing(method_name, *args, &block)
49-
method = method_name.gsub(/_as_node$/, '') # remove once _as_node is deprecated.
49+
method = method_name.gsub(/_as_node$/, '') # remove once _as_node is deprecated.
5050
component_class = get_const(method) if const_defined?(method)
5151
component_class ||= import_const_from_native(self, method, false)
5252
raise 'could not import a react component named: '\
@@ -63,8 +63,10 @@ def method_missing(method_name, *args, &block)
6363
def lookup_native_name(js_name)
6464
native_name = scope_native_name(js_name)
6565
`eval(#{native_name}) !== undefined && native_name`
66-
rescue
66+
# rubocop:disable Lint/RescueException # that is what eval raises in Opal >= 0.10.
67+
rescue Exception
6768
nil
69+
# rubocop:enable Lint/RescueException
6870
end
6971

7072
def scope_native_name(js_name)

lib/reactive-ruby/component_loader.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ def components
3434
end
3535

3636
def opal(file)
37-
Opal::Processor.load_asset_code(assets, file)
37+
if Opal::Processor.respond_to?(:load_asset_code)
38+
Opal::Processor.load_asset_code(assets, file)
39+
else
40+
Opal::Sprockets.load_asset(file, assets)
41+
end
3842
rescue # What exception is being caught here?
3943
end
4044

lib/reactive-ruby/isomorphic_helpers.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def send_to_opal(method, *args)
105105
return unless @ctx
106106
args = [1] if args.length == 0
107107
::ReactiveRuby::ComponentLoader.new(@ctx).load!
108-
@ctx.eval("Opal.React.IsomorphicHelpers.$#{method}(#{args.collect { |arg| "'#{arg}'"}.join(', ')})")
108+
@ctx.eval("Opal.React.$const_get('IsomorphicHelpers').$#{method}(#{args.collect { |arg| "'#{arg}'"}.join(', ')})")
109109
end
110110

111111
def self.register_before_first_mount_block(&block)

0 commit comments

Comments
 (0)