UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

41 lines (40 loc) 1.17 kB
import { isValidElement } from "react"; function filterRootHTML(el) { var htmlProps, bodyProps, head; function traverse(element) { if (!element || typeof element != "object") return element; if (Array.isArray(element)) return element.map(traverse); var reactElement = element, { type, props } = reactElement; if (type === "html") { var { children: children2, ...restProps } = reactElement.props; return htmlProps = restProps, traverse(children2); } if (type === "head") return head = reactElement, null; if (type === "body") { var { children: children1, ...restProps1 } = reactElement.props; return bodyProps = restProps1, children1; } return isValidElement(element) && typeof element.type == "string" && element.type.toLowerCase() === element.type ? null : element; } var children = traverse(el) || // if none found, we assume they aren't returning any html so just pass it on el; return { children, htmlProps, bodyProps, head }; } export { filterRootHTML }; //# sourceMappingURL=filterRootHTML.native.js.map