UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

1 lines • 1.84 kB
{"version":3,"file":"filterRootHTML.js","names":[],"sources":["esm/router/filterRootHTML.js"],"sourcesContent":["\n\nfunction filterRootHTML(el) {\n\tlet htmlProps;\n\tlet bodyProps;\n\tlet head;\n\tfunction traverse(element) {\n\t\tif (!element || typeof element !== \"object\") return element;\n\t\tif (Array.isArray(element)) return element.map(traverse);\n\t\tconst reactElement = element;\n\t\tconst { type, props } = reactElement;\n\t\tif (type === \"html\") {\n\t\t\tif (props && typeof props === \"object\" && \"children\" in props) {\n\t\t\t\tconst { children: children2, ...restProps } = props;\n\t\t\t\thtmlProps = restProps;\n\t\t\t\treturn traverse(children2);\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\tif (type === \"head\") {\n\t\t\thead = reactElement;\n\t\t\treturn null;\n\t\t}\n\t\tif (type === \"body\") {\n\t\t\tif (props && typeof props === \"object\" && \"children\" in props) {\n\t\t\t\tconst { children: children2, ...restProps } = props;\n\t\t\t\tbodyProps = restProps;\n\t\t\t\treturn children2;\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\treturn element;\n\t}\n\treturn {\n\t\tchildren: traverse(el) || el,\n\t\thtmlProps,\n\t\tbodyProps,\n\t\thead\n\t};\n}\n\nexport { filterRootHTML };"],"mappings":";AAEA,SAAS,eAAe,IAAI;CAC3B,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,SAAS,SAAS,SAAS;EAC1B,IAAI,CAAC,WAAW,OAAO,YAAY,UAAU,OAAO;EACpD,IAAI,MAAM,QAAQ,OAAO,GAAG,OAAO,QAAQ,IAAI,QAAQ;EACvD,MAAM,eAAe;EACrB,MAAM,EAAE,MAAM,UAAU;EACxB,IAAI,SAAS,QAAQ;GACpB,IAAI,SAAS,OAAO,UAAU,YAAY,cAAc,OAAO;IAC9D,MAAM,EAAE,UAAU,WAAW,GAAG,cAAc;IAC9C,YAAY;IACZ,OAAO,SAAS,SAAS;GAC1B;GACA,OAAO;EACR;EACA,IAAI,SAAS,QAAQ;GACpB,OAAO;GACP,OAAO;EACR;EACA,IAAI,SAAS,QAAQ;GACpB,IAAI,SAAS,OAAO,UAAU,YAAY,cAAc,OAAO;IAC9D,MAAM,EAAE,UAAU,WAAW,GAAG,cAAc;IAC9C,YAAY;IACZ,OAAO;GACR;GACA,OAAO;EACR;EACA,OAAO;CACR;CACA,OAAO;EACN,UAAU,SAAS,EAAE,KAAK;EAC1B;EACA;EACA;CACD;AACD"}