src/helpers/runtime/render-arbitrary.js
function renderArbitraryAST(plugin, ref, deps) {
  const { hasOwn } = deps;
  const child = t.identifier("child");
  const type = t.identifier("type");
  const func = t.identifier("func");
  const args = t.identifier("args");
  const i = t.identifier("i");
  const prop = t.identifier("prop");

  /**
   * function _renderArbitrary(child) {
   *   var type = typeof child;
   *   if (type === "number" || (type === string || type === 'object' && child instanceof String)) {
   *     text(child);
   *   } else if (Array.isArray(child)) {
   *     for (var i = 0; i < child.length; i++) {
   *       _renderArbitrary(child[i]);
   *     }
   *   } else if (type === "object") {
   *     if (child.__jsxDOMWrapper) {
   *       var func = child.func, args = child.args;
   *       if (args) {
   *         func.apply(this, args);
   *       } else {
   *         func();
   *       }
   *     } else if (String(child) === "[object Object]") {
   *       for (var prop in child) {
   *         if (_hasOwn.call(child, prop)) {
   *           renderArbitrary(child[prop])
   *         }
   *       }
   *     }
   *   }
   * }
   */
  return t.functionExpression(
    ref,
    [child],
    t.blockStatement([
      t.variableDeclaration("var", [
        t.variableDeclarator(
          type,
          t.unaryExpression("typeof", child)
        )
      ]),
      t.IfStatement(
        isTextual(type, child),
        t.blockStatement([
          t.expressionStatement(toFunctionCall(iDOMMethod("text", plugin), [child]))
        ]),
        t.ifStatement(
          isArray(child),
          t.blockStatement([
            t.forStatement(
              t.variableDeclaration("var", [t.variableDeclarator(i, t.numericLiteral(0))]),
              t.binaryExpression("<", i, t.memberExpression(child, t.identifier("length"))),
              t.updateExpression("++", i),
              t.expressionStatement(toFunctionCall(ref, [
                t.memberExpression(child, i, true)
              ]))
            )
          ]),
          t.ifStatement(
            isObject(type),
            t.blockStatement([
              t.ifStatement(
                isDOMWrapper(child),
                t.blockStatement([
                  t.variableDeclaration("var", [
                    t.variableDeclarator(func, t.memberExpression(child, func)),
                    t.variableDeclarator(args, t.memberExpression(child, args))
                  ]),
                  t.ifStatement(
                    args,
                    t.blockStatement([
                      t.expressionStatement(
                        toFunctionCall(t.memberExpression(func, t.identifier("apply")), [t.thisExpression(), args]),
                      )
                    ]),
                    t.blockStatement([
                      t.expressionStatement(toFunctionCall(func, [])),
                    ]),
                  )
                ]),
                t.ifStatement(
                  isPlainObject(child),
                  t.blockStatement([
                    t.forInStatement(
                      t.variableDeclaration("var", [t.variableDeclarator(prop)]),
                      child,
                      t.ifStatement(
                        toFunctionCall(t.memberExpression(
                          hasOwn,
                          t.identifier("call")
                        ), [child, i]),
                        t.expressionStatement(toFunctionCall(ref, [
                          t.memberExpression(child, i, true)
                        ]))
                      )
                    )
                  ])
                )
              )
            ])
          )
        )
      )
    ])
  );
}
function renderArbitraryAST(plugin, ref, deps) {
  const { hasOwn } = deps;
  const child = t.identifier("child");
  const type = t.identifier("type");
  const func = t.identifier("func");
  const args = t.identifier("args");
  const i = t.identifier("i");
  const prop = t.identifier("prop");

  /**
   * function _renderArbitrary(child) {
   *   var type = typeof child;
   *   if (type === "number" || (type === string || type === 'object' && child instanceof String)) {
   *     text(child);
   *   } else if (Array.isArray(child)) {
   *     for (var i = 0; i < child.length; i++) {
   *       _renderArbitrary(child[i]);
   *     }
   *   } else if (type === "object") {
   *     if (child.__jsxDOMWrapper) {
   *       var func = child.func, args = child.args;
   *       if (args) {
   *         func.apply(this, args);
   *       } else {
   *         func();
   *       }
   *     } else if (String(child) === "[object Object]") {
   *       for (var prop in child) {
   *         if (_hasOwn.call(child, prop)) {
   *           renderArbitrary(child[prop])
   *         }
   *       }
   *     }
   *   }
   * }
   */
  return t.functionExpression(
    ref,
    [child],
    t.blockStatement([
      t.variableDeclaration("var", [
        t.variableDeclarator(
          type,
          t.unaryExpression("typeof", child)
        )
      ]),
      t.IfStatement(
        isTextual(type, child),
        t.blockStatement([
          t.expressionStatement(toFunctionCall(iDOMMethod("text", plugin), [child]))
        ]),
        t.ifStatement(
          isArray(child),
          t.blockStatement([
            t.forStatement(
              t.variableDeclaration("var", [t.variableDeclarator(i, t.numericLiteral(0))]),
              t.binaryExpression("<", i, t.memberExpression(child, t.identifier("length"))),
              t.updateExpression("++", i),
              t.expressionStatement(toFunctionCall(ref, [
                t.memberExpression(child, i, true)
              ]))
            )
          ]),
          t.ifStatement(
            isObject(type),
            t.blockStatement([
              t.ifStatement(
                isDOMWrapper(child),
                t.blockStatement([
                  t.variableDeclaration("var", [
                    t.variableDeclarator(func, t.memberExpression(child, func)),
                    t.variableDeclarator(args, t.memberExpression(child, args))
                  ]),
                  t.ifStatement(
                    args,
                    t.blockStatement([
                      t.expressionStatement(
                        toFunctionCall(t.memberExpression(func, t.identifier("apply")), [t.thisExpression(), args]),
                      )
                    ]),
                    t.blockStatement([
                      t.expressionStatement(toFunctionCall(func, [])),
                    ]),
                  )
                ]),
                t.ifStatement(
                  isPlainObject(child),
                  t.blockStatement([
                    t.forInStatement(
                      t.variableDeclaration("var", [t.variableDeclarator(prop)]),
                      child,
                      t.ifStatement(
                        toFunctionCall(t.memberExpression(
                          hasOwn,
                          t.identifier("call")
                        ), [child, i]),
                        t.expressionStatement(toFunctionCall(ref, [
                          t.memberExpression(child, i, true)
                        ]))
                      )
                    )
                  ])
                )
              )
            ])
          )
        )
      )
    ])
  );
}
function renderArbitraryAST ( plugin , ref , deps ) { const { hasOwn } = deps ; const child = t . identifier ( "child" ) ; const type = t . identifier ( "type" ) ; const func = t . identifier ( "func" ) ; const args = t . identifier ( "args" ) ; const i = t . identifier ( "i" ) ; const prop = t . identifier ( "prop" ) ; /**
   * function _renderArbitrary(child) {
   *   var type = typeof child;
   *   if (type === "number" || (type === string || type === 'object' && child instanceof String)) {
   *     text(child);
   *   } else if (Array.isArray(child)) {
   *     for (var i = 0; i < child.length; i++) {
   *       _renderArbitrary(child[i]);
   *     }
   *   } else if (type === "object") {
   *     if (child.__jsxDOMWrapper) {
   *       var func = child.func, args = child.args;
   *       if (args) {
   *         func.apply(this, args);
   *       } else {
   *         func();
   *       }
   *     } else if (String(child) === "[object Object]") {
   *       for (var prop in child) {
   *         if (_hasOwn.call(child, prop)) {
   *           renderArbitrary(child[prop])
   *         }
   *       }
   *     }
   *   }
   * }
   */ return t . functionExpression ( ref , [ child ] , t . blockStatement ( [ t . variableDeclaration ( "var" , [ t . variableDeclarator ( type , t . unaryExpression ( "typeof" , child ) ) ] ) , t . IfStatement ( isTextual ( type , child ) , t . blockStatement ( [ t . expressionStatement ( toFunctionCall ( iDOMMethod ( "text" , plugin ) , [ child ] ) ) ] ) , t . ifStatement ( isArray ( child ) , t . blockStatement ( [ t . forStatement ( t . variableDeclaration ( "var" , [ t . variableDeclarator ( i , t . numericLiteral ( 0 ) ) ] ) , t . binaryExpression ( "<" , i , t . memberExpression ( child , t . identifier ( "length" ) ) ) , t . updateExpression ( "++" , i ) , t . expressionStatement ( toFunctionCall ( ref , [ t . memberExpression ( child , i , true ) ] ) ) ) ] ) , t . ifStatement ( isObject ( type ) , t . blockStatement ( [ t . ifStatement ( isDOMWrapper ( child ) , t . blockStatement ( [ t . variableDeclaration ( "var" , [ t . variableDeclarator ( func , t . memberExpression ( child , func ) ) , t . variableDeclarator ( args , t . memberExpression ( child , args ) ) ] ) , t . ifStatement ( args , t . blockStatement ( [ t . expressionStatement ( toFunctionCall ( t . memberExpression ( func , t . identifier ( "apply" ) ) , [ t . thisExpression ( ) , args ] ) , ) ] ) , t . blockStatement ( [ t . expressionStatement ( toFunctionCall ( func , [ ] ) ) , ] ) , ) ] ) , t . ifStatement ( isPlainObject ( child ) , t . blockStatement ( [ t . forInStatement ( t . variableDeclaration ( "var" , [ t . variableDeclarator ( prop ) ] ) , child , t . ifStatement ( toFunctionCall ( t . memberExpression ( hasOwn , t . identifier ( "call" ) ) , [ child , i ] ) , t . expressionStatement ( toFunctionCall ( ref , [ t . memberExpression ( child , i , true ) ] ) ) ) ) ] ) ) ) ] ) ) ) ) ] ) ) ; }
Renders an arbitrary JSX Expression into the DOM. Valid types are strings, numbers, and JSX element closures. It may also be an Array or Object, which will be iterated recursively to find a valid type.
Renders an arbitrary JSX Expression into the DOM . Valid types are strings numbers and JSX element closures . It may also be an Array or Object which will be iterated recursively to find a valid type .