lib/react/component/resolution.rb in isomorfeus-react-16.6.8 vs lib/react/component/resolution.rb in isomorfeus-react-16.8.0
- old
+ new
@@ -32,44 +32,43 @@
%x{
var component = null;
var component_type = typeof Opal.global[component_name];
if (component_type === "function" || component_type === "object") {
component = Opal.global[component_name];
- }
- else {
+ } else {
var modules = self.$class().$to_s().split("::");
var modules_length = modules.length - 1;
- // modules.unshift('');
var module;
var constant;
for (var i = modules_length; i > 0; i--) {
try {
module = modules.slice(0, i).join('::')
constant = self.$class().$const_get(module).$const_get(component_name, false);
- component_type = typeof constant.react_component;
- if (component_type === "function" || component_type === "object") {
+ if (typeof constant.react_component !== 'undefined') {
component = constant.react_component;
break;
}
- }
- catch(err) {
+ } catch(err) {
component = null;
}
}
+ if (!component) {
+ try {
+ constant = Opal.Object.$const_get(component_name);
+ if (typeof constant.react_component !== 'undefined') {
+ component = constant.react_component;
+ }
+ } catch(err) {
+ component = null
+ }
+ }
}
if (component) {
- if (args.length > 0) {
- var last_arg = args[args.length - 1];
- if (typeof last_arg === 'string' || last_arg instanceof String) {
- if (args.length === 1) { Opal.React.internal_render(component, null, last_arg, null); }
- else { Opal.React.internal_render(component, args[0], last_arg, null); }
- } else { Opal.React.internal_render(component, args[0], null, block); }
- } else { Opal.React.internal_render(component, null, null, block); }
+ Opal.React.internal_prepare_args_and_render(component, args, block);
} else {
return #{_react_component_resolution_original_method_missing(component_name, *args, block)};
}
}
end
-
end
end
end
\ No newline at end of file