lib/react/component/api.rb in isomorfeus-react-16.6.2 vs lib/react/component/api.rb in isomorfeus-react-16.6.3
- old
+ new
@@ -5,26 +5,28 @@
base.instance_exec do
base_module = base.to_s.deconstantize
if base_module != ''
base_module.constantize.define_singleton_method(base.to_s.demodulize) do |*args, &block|
%x{
- var props = null;
-
if (args.length > 0) {
- props = Opal.React.to_native_react_props(args[0]);
- }
- Opal.React.internal_render(#{base}.react_component, props, block);
+ var last_arg = args[args.length - 1];
+ if (typeof last_arg === 'string' || last_arg instanceof String) {
+ if (args.length === 1) { Opal.React.internal_render(#{base}.react_component, null, last_arg, null); }
+ else { Opal.React.internal_render(#{base}.react_component, args[0], last_arg, null); }
+ } else { Opal.React.internal_render(#{base}.react_component, args[0], null, block); }
+ } else { Opal.React.internal_render(#{base}.react_component, null, null, block); }
}
end
else
Object.define_method(base.to_s) do |*args, &block|
%x{
- var props = null;
-
if (args.length > 0) {
- props = Opal.React.to_native_react_props(args[0]);
- }
- Opal.React.internal_render(#{base}.react_component, props, block);
+ var last_arg = args[args.length - 1];
+ if (typeof last_arg === 'string' || last_arg instanceof String) {
+ if (args.length === 1) { Opal.React.internal_render(#{base}.react_component, null, last_arg, null); }
+ else { Opal.React.internal_render(#{base}.react_component, args[0], last_arg, null); }
+ } else { Opal.React.internal_render(#{base}.react_component, args[0], null, block); }
+ } else { Opal.React.internal_render(#{base}.react_component, null, null, block); }
}
end
end
\ No newline at end of file