UNPKG

@sentry/browser

Version:
26 lines (23 loc) 845 B
import { isElement, htmlTreeAsString } from '@sentry-internal/browser-utils'; const HTML_ELEMENT_CONSTRUCTOR_NAME_REGEX = /^HTML(\w*)Element$/; function normalizeStringifyValue(value) { if (typeof window !== "undefined" && value === window) { return "[Window]"; } if (typeof document !== "undefined" && value === document) { return "[Document]"; } if (isElement(value)) { const objName = getConstructorName(value); if (HTML_ELEMENT_CONSTRUCTOR_NAME_REGEX.test(objName)) { return `[HTMLElement: ${htmlTreeAsString(value)}]`; } } return void 0; } function getConstructorName(value) { const prototype = Object.getPrototypeOf(value); return prototype?.constructor ? prototype.constructor.name : "null prototype"; } export { normalizeStringifyValue }; //# sourceMappingURL=normalizeStringifyValue.js.map