UNPKG

@sentry/browser

Version:
28 lines (24 loc) 954 B
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const browserUtils = require('@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 (browserUtils.isElement(value)) { const objName = getConstructorName(value); if (HTML_ELEMENT_CONSTRUCTOR_NAME_REGEX.test(objName)) { return `[HTMLElement: ${browserUtils.htmlTreeAsString(value)}]`; } } return void 0; } function getConstructorName(value) { const prototype = Object.getPrototypeOf(value); return prototype?.constructor ? prototype.constructor.name : "null prototype"; } exports.normalizeStringifyValue = normalizeStringifyValue; //# sourceMappingURL=normalizeStringifyValue.js.map