UNPKG

next-csrf

Version:

CSRF mitigation library for Next.js

30 lines (23 loc) 803 B
import contextToElement from '../util/context-to-element'; export default function () { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, context = _ref.context; var element = contextToElement({ label: 'get/shadow-host', context: context }); // walk up to the root var container = null; while (element) { container = element; element = element.parentNode; } // https://developer.mozilla.org/en-US/docs/Web/API/Node.nodeType // NOTE: Firefox 34 does not expose ShadowRoot.host (but 37 does) if (container.nodeType === container.DOCUMENT_FRAGMENT_NODE && container.host) { // the root is attached to a fragment node that has a host return container.host; } return null; } //# sourceMappingURL=shadow-host.js.map