@stratakit/foundations
Version:
Foundational pieces of StrataKit
32 lines (31 loc) • 858 B
JavaScript
import * as React from "react";
const isBrowser = typeof document !== "undefined";
const supportsPopover = isBrowser && "popover" in HTMLElement.prototype;
function isDocument(node) {
return node?.nodeType === Node.DOCUMENT_NODE;
}
function getOwnerDocument(node) {
if (!node) return null;
return (isDocument(node) ? node : node.ownerDocument) || null;
}
function getWindow(node) {
const ownerDocument = getOwnerDocument(node);
return ownerDocument?.defaultView || null;
}
function parseDOM(htmlString, { ownerDocument }) {
const template = ownerDocument.createElement("template");
template.innerHTML = htmlString;
return template.content;
}
const forwardRef = React.forwardRef;
const identity = (value) => value;
export {
forwardRef,
getOwnerDocument,
getWindow,
identity,
isBrowser,
isDocument,
parseDOM,
supportsPopover
};