{"ScriptPreparationCode":"\r\nconst matchHtmlRegExp = /[\u0022\u0027\u0026\u003C\u003E]/\r\n\r\nconst escapeHTML = function (string) {\r\n const str = string \u002B \u0027\u0027\r\n const match = matchHtmlRegExp.exec(str)\r\n\r\n if (!match) {\r\n return str\r\n }\r\n\r\n let escape\r\n let html = \u0027\u0027\r\n let index = 0\r\n let lastIndex = 0\r\n\r\n for (index = match.index; index \u003C str.length; index\u002B\u002B) {\r\n switch (str.charCodeAt(index)) {\r\n case 34: escape = \u0027\u0026quot;\u0027; break\r\n case 38: escape = \u0027\u0026amp;\u0027; break\r\n case 39: escape = \u0027\u0026#39;\u0027; break\r\n case 60: escape = \u0027\u0026lt;\u0027; break\r\n case 62: escape = \u0027\u0026gt;\u0027; break\r\n default: continue\r\n }\r\n\r\n if (lastIndex !== index) {\r\n html \u002B= str.substring(lastIndex, index)\r\n }\r\n\r\n lastIndex = index \u002B 1\r\n html \u002B= escape\r\n }\r\n\r\n return lastIndex !== index\r\n ? html \u002B str.substring(lastIndex, index)\r\n : html\r\n}\r\n\r\n// ===\r\n\r\nconst voidTags = [\u0027area\u0027, \u0027base\u0027, \u0027br\u0027, \u0027col\u0027, \u0027command\u0027, \u0027embed\u0027, \u0027hr\u0027, \u0027img\u0027,\r\n \u0027input\u0027, \u0027keygen\u0027, \u0027link\u0027, \u0027meta\u0027, \u0027param\u0027, \u0027source\u0027, \u0027track\u0027, \u0027wbr\u0027]\r\n\r\nconst isSafe = value =\u003E {\r\n switch (typeof value) {\r\n case \u0027boolean\u0027: return true\r\n case \u0027number\u0027: return true\r\n case \u0027string\u0027: return true\r\n }\r\n}\r\n\r\nconst joinChildren = children =\u003E {\r\n let target = \u0027\u0027\r\n\r\n if (typeof children === \u0027string\u0027) {\r\n return children\r\n }\r\n\r\n if (Array.isArray(children) === true) {\r\n for (let i = 0; i \u003C children.length; i\u002B\u002B) {\r\n const child = children[i]\r\n const value = Array.isArray(child) ? child.join(\u0027\u0027) : child\r\n\r\n if (isSafe(value)) {\r\n target \u002B= value\r\n }\r\n }\r\n }\r\n\r\n return target\r\n}\r\n\r\nconst joinProps = props =\u003E {\r\n let target = \u0027\u0027\r\n\r\n for (const key in props) {\r\n const value = props[key]\r\n\r\n if (isSafe(value) === true) {\r\n target \u002B= \u0027 \u0027 \u002B key \u002B \u0027=\u0022\u0027 \u002B escapeHTML(value) \u002B \u0027\u0022\u0027\r\n }\r\n }\r\n\r\n return target\r\n}\r\n\r\nconst renderNode = (tag, props, children) =\u003E {\r\n const target = \u0027\u003C\u0027 \u002B tag \u002B joinProps(props)\r\n\r\n if (voidTags.includes(tag) === true) {\r\n return target \u002B \u0027/\u003E\u0027\r\n }\r\n\r\n return target \u002B \u0027\u003E\u0027 \u002B joinChildren(children) \u002B \u0027\u003C/\u0027 \u002B tag \u002B \u0027\u003E\u0027\r\n}\r\n\r\nconst renderText = value =\u003E escapeHTML(value)\r\n\r\nconst node = renderNode\r\nconst text = renderText\r\n\r\n// ===\r\n\r\nfunction render (jsx) {\r\n return jsx(\u0022div\u0022, null,\r\n jsx(\u0022div\u0022, null, \u0022Hello\u0022),\r\n jsx(\u0022div\u0022, null, \u0022Hello\u0022),\r\n jsx(\u0022div\u0022, null, \u0022Hello\u0022),\r\n jsx(\u0022div\u0022, null, \u0022Hello\u0022),\r\n jsx(\u0022div\u0022, null, \u0022Hello\u0022),\r\n jsx(\u0022div\u0022, null, \u0022Hello\u0022),\r\n jsx(\u0022div\u0022, null, \u0022Hello\u0022),\r\n jsx(\u0022div\u0022, null, \u0022Hello\u0022))\r\n}\r\n\r\n// ===\r\n\r\nfunction render_with_rest (type, props, ...children) {\r\n props = props == null ? {} : props\r\n\r\n if (typeof type === \u0027function\u0027) {\r\n return type(props, flatten(children))\r\n }\r\n\r\n for (let i = 0; i \u003C children.length; i\u002B\u002B) {\r\n const child = children[i]\r\n children[i] = Array.isArray(child) ? child[0] : text(child)\r\n }\r\n\r\n return [node(type, props, children)]\r\n}\r\n\r\nfunction render_with_arguments (type, props) {\r\n var children = []\r\n\r\n for (var i = 2; i \u003C arguments.length; i\u002B\u002B) {\r\n children[i - 2] = arguments[i]\r\n }\r\n\r\n props = props == null ? {} : props;\r\n \r\n if (typeof type === \u0027function\u0027) {\r\n return type(props, flatten(children))\r\n }\r\n \r\n for (var i = 0; i \u003C children.length; i\u002B\u002B) {\r\n var child = children[i]\r\n children[i] = Array.isArray(child) ? child[0] : text(child)\r\n }\r\n \r\n return [node(type, props, children)]\r\n}","TestCases":[{"Name":"rest params","Code":"render(render_with_rest)","IsDeferred":false},{"Name":"arguments","Code":"render(render_with_arguments)","IsDeferred":false}]}