'use strict';

let htmlParser = require('parse5');
let React = require('react');
let convertAttr = require('react-attr-converter');

let renderNode = (node, key) => {
  if (node.nodeName === '#text') {
    return node.value;
  }

  let attr = node.attrs.reduce((result, attr) => {
    result[convertAttr(attr.name)] = attr.value;
    return result;
  }, {key});

  let children = node.childNodes.map(renderNode);
  return React.createElement(node.tagName, attr, children);
};

let renderHTML = (html) => {
  let htmlAST = htmlParser.parseFragment(html);

  if (htmlAST.childNodes.length === 0) {
    return null;
  }

  let result = htmlAST.childNodes.map(renderNode);

  return result.length === 1 ? result[0] : result;
};

module.exports = renderHTML;
module.exports.renderHTML = renderHTML;

@@ -8,19 +8,19 @@
 rict';%0A%0A
-let
+var
  htmlPar
@@ -44,19 +44,19 @@
 rse5');%0A
-let
+var
  React =
@@ -74,19 +74,19 @@
 eact');%0A
-let
+var
  convert
@@ -126,19 +126,19 @@
 ter');%0A%0A
-let
+var
  renderN
@@ -142,16 +142,25 @@
 erNode =
+ function
  (node, 
@@ -163,19 +163,16 @@
 de, key)
- =%3E
  %7B%0A  if 
@@ -231,19 +231,19 @@
 %0A  %7D%0A%0A  
-let
+var
  attr = 
@@ -260,16 +260,25 @@
 .reduce(
+function 
 (result,
@@ -283,19 +283,16 @@
 t, attr)
- =%3E
  %7B%0A    r
@@ -370,19 +370,19 @@
 y%7D);%0A%0A  
-let
+var
  childre
@@ -482,19 +482,19 @@
 n);%0A%7D;%0A%0A
-let
+var
  renderH
@@ -502,26 +502,32 @@
 ML =
+ function
  (html)
- =%3E
  %7B%0A  
-let
+var
  htm
@@ -635,11 +635,11 @@
 %0A%0A  
-let
+var
  res

Support ES5