@primer/react
Version:
An implementation of GitHub's Primer Design System using React
16 lines (14 loc) • 701 B
JavaScript
/**
* Determines whether a given element is a valid slot for the supplied slot component
*/
function isSlot(element, slot) {
var _reactElement$__SLOT_, _reactElement$type;
const elementType = typeof element;
if (elementType !== 'object' && elementType !== 'function' && element != null) {
return false;
}
const reactElement = element;
const elementSlot = (_reactElement$__SLOT_ = reactElement.__SLOT__) !== null && _reactElement$__SLOT_ !== void 0 ? _reactElement$__SLOT_ : (_reactElement$type = reactElement.type) === null || _reactElement$type === void 0 ? void 0 : _reactElement$type.__SLOT__;
return slot.__SLOT__ ? elementSlot === slot.__SLOT__ : false;
}
export { isSlot };