lib/react/component/elements.rb in isomorfeus-react-16.6.8 vs lib/react/component/elements.rb in isomorfeus-react-16.8.0

- old
+ new

@@ -1,9 +1,10 @@ module React module Component module Elements # https://www.w3.org/TR/html52/fullindex.html#index-elements + # https://www.w3.org/TR/SVG11/eltindex.html SUPPORTED_HTML_AND_SVG_ELEMENTS = %w[ a abbr address area article aside audio b base bdi bdo blockquote body br button canvas caption cite code col colgroup data datalist dd del details dfn dialog div dl dt @@ -22,14 +23,10 @@ s samp script section select small source span strong style sub summary sup table tbody td template textarea tfoot th thead time title tr track u ul var video wbr - ] + - # https://www.w3.org/TR/SVG11/eltindex.html - # elements listed above not mentioned a second time - %w[ altGlyph altGlyphDef altGlyphItem animate animateColor animateMotion animateTransform circle clipPath color-profile cursor defs desc ellipse feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting @@ -48,32 +45,15 @@ text textPath tref tspan use view vkern ] - SUPPORTED_HTML_AND_SVG_ELEMENTS.each do |element| define_method(element) do |*args, &block| - %x{ - 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(element, null, last_arg, null); } - else { Opal.React.internal_render(element, args[0], last_arg, null); } - } else { Opal.React.internal_render(element, args[0], null, block); } - } else { Opal.React.internal_render(element, null, null, block); } - } + `Opal.React.internal_prepare_args_and_render(element, args, block)` end define_method(`element.toUpperCase()`) do |*args, &block| - %x{ - 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(element, null, last_arg, null); } - else { Opal.React.internal_render(element, args[0], last_arg, null); } - } else { Opal.React.internal_render(element, args[0], null, block); } - } else { Opal.React.internal_render(element, null, null, block); } - } + `Opal.React.internal_prepare_args_and_render(element, args, block)` end end end end end