@posthog/rrweb-record 0.0.39 → 0.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1134,6 +1134,8 @@ function slimDOMExcluded(sn, slimDOMOptions) {
1134
1134
  }
1135
1135
  return false;
1136
1136
  }
1137
+ const DEFAULT_MAX_DEPTH = 50;
1138
+ let _maxDepthWarned = false;
1137
1139
  function serializeNodeWithId(n2, options) {
1138
1140
  const {
1139
1141
  doc,
@@ -1157,10 +1159,21 @@ function serializeNodeWithId(n2, options) {
1157
1159
  onStylesheetLoad,
1158
1160
  stylesheetLoadTimeout = 5e3,
1159
1161
  keepIframeSrcFn = () => false,
1160
- newlyAddedElement = false
1162
+ newlyAddedElement = false,
1163
+ depth = 0,
1164
+ maxDepth = DEFAULT_MAX_DEPTH
1161
1165
  } = options;
1162
1166
  let { needsMask } = options;
1163
1167
  let { preserveWhiteSpace = true } = options;
1168
+ if (depth >= maxDepth) {
1169
+ if (!_maxDepthWarned) {
1170
+ _maxDepthWarned = true;
1171
+ console.warn(
1172
+ `[rrweb-snapshot] DOM tree depth exceeded max depth of ${maxDepth}. Children beyond this depth will not be recorded. This may indicate deeply nested DOM structures.`
1173
+ );
1174
+ }
1175
+ return null;
1176
+ }
1164
1177
  if (!needsMask) {
1165
1178
  const checkAncestors = needsMask === void 0;
1166
1179
  needsMask = needMaskingText(
@@ -1241,7 +1254,9 @@ function serializeNodeWithId(n2, options) {
1241
1254
  iframeLoadTimeout,
1242
1255
  onStylesheetLoad,
1243
1256
  stylesheetLoadTimeout,
1244
- keepIframeSrcFn
1257
+ keepIframeSrcFn,
1258
+ depth: depth + 1,
1259
+ maxDepth
1245
1260
  };
1246
1261
  if (serializedNode.type === NodeType$1$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1247
1262
  else {
@@ -1296,7 +1311,9 @@ function serializeNodeWithId(n2, options) {
1296
1311
  iframeLoadTimeout,
1297
1312
  onStylesheetLoad,
1298
1313
  stylesheetLoadTimeout,
1299
- keepIframeSrcFn
1314
+ keepIframeSrcFn,
1315
+ depth: depth + 1,
1316
+ maxDepth
1300
1317
  });
1301
1318
  if (serializedIframeNode) {
1302
1319
  onIframeLoad(
@@ -1337,7 +1354,9 @@ function serializeNodeWithId(n2, options) {
1337
1354
  iframeLoadTimeout,
1338
1355
  onStylesheetLoad,
1339
1356
  stylesheetLoadTimeout,
1340
- keepIframeSrcFn
1357
+ keepIframeSrcFn,
1358
+ depth,
1359
+ maxDepth
1341
1360
  });
1342
1361
  if (serializedLinkNode) {
1343
1362
  onStylesheetLoad(
@@ -1373,7 +1392,8 @@ function snapshot(n2, options) {
1373
1392
  iframeLoadTimeout,
1374
1393
  onStylesheetLoad,
1375
1394
  stylesheetLoadTimeout,
1376
- keepIframeSrcFn = () => false
1395
+ keepIframeSrcFn = () => false,
1396
+ maxDepth
1377
1397
  } = options || {};
1378
1398
  const maskInputOptions = maskAllInputs === true ? {
1379
1399
  color: true,
@@ -1434,7 +1454,8 @@ function snapshot(n2, options) {
1434
1454
  onStylesheetLoad,
1435
1455
  stylesheetLoadTimeout,
1436
1456
  keepIframeSrcFn,
1437
- newlyAddedElement: false
1457
+ newlyAddedElement: false,
1458
+ maxDepth
1438
1459
  });
1439
1460
  }
1440
1461
  function getDefaultExportFromCjs$1(x) {