lib/react/component/resolution.rb in isomorfeus-react-16.6.6 vs lib/react/component/resolution.rb in isomorfeus-react-16.6.7

- old
+ new

@@ -4,12 +4,13 @@ def self.included(base) base.instance_exec do alias _react_component_resolution_original_const_missing const_missing def const_missing(const_name) + # language=JS %x{ - if (typeof Opal.global[const_name] == "object") { + if (typeof Opal.global[const_name] === "object") { var new_const = #{React::NativeConstantWrapper.new(`Opal.global[const_name]`, const_name)}; #{Object.const_set(const_name, `new_const`)}; return new_const; } else { return #{_react_component_resolution_original_const_missing(const_name)}; @@ -28,11 +29,12 @@ # second check for ruby component and render it, they are a bit slower anyway # third pass on method missing # language=JS %x{ var component = null; - if (typeof Opal.global[component_name] == "function") { + var component_type = typeof Opal.global[component_name]; + if (component_type === "function" || component_type === "object") { component = Opal.global[component_name]; } else { var modules = self.$class().$to_s().split("::"); var modules_length = modules.length - 1; @@ -41,10 +43,11 @@ 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); - if (typeof constant.react_component == "function") { + component_type = typeof constant.react_component; + if (component_type === "function" || component_type === "object") { component = constant.react_component; break; } } catch(err) { \ No newline at end of file