@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.
@@ -1169,6 +1169,8 @@ function slimDOMExcluded(sn, slimDOMOptions) {
1169
1169
  }
1170
1170
  return false;
1171
1171
  }
1172
+ const DEFAULT_MAX_DEPTH = 50;
1173
+ let _maxDepthWarned = false;
1172
1174
  function serializeNodeWithId(n2, options) {
1173
1175
  const {
1174
1176
  doc,
@@ -1192,10 +1194,21 @@ function serializeNodeWithId(n2, options) {
1192
1194
  onStylesheetLoad,
1193
1195
  stylesheetLoadTimeout = 5e3,
1194
1196
  keepIframeSrcFn = () => false,
1195
- newlyAddedElement = false
1197
+ newlyAddedElement = false,
1198
+ depth = 0,
1199
+ maxDepth = DEFAULT_MAX_DEPTH
1196
1200
  } = options;
1197
1201
  let { needsMask } = options;
1198
1202
  let { preserveWhiteSpace = true } = options;
1203
+ if (depth >= maxDepth) {
1204
+ if (!_maxDepthWarned) {
1205
+ _maxDepthWarned = true;
1206
+ console.warn(
1207
+ `[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.`
1208
+ );
1209
+ }
1210
+ return null;
1211
+ }
1199
1212
  if (!needsMask) {
1200
1213
  const checkAncestors = needsMask === void 0;
1201
1214
  needsMask = needMaskingText(
@@ -1276,7 +1289,9 @@ function serializeNodeWithId(n2, options) {
1276
1289
  iframeLoadTimeout,
1277
1290
  onStylesheetLoad,
1278
1291
  stylesheetLoadTimeout,
1279
- keepIframeSrcFn
1292
+ keepIframeSrcFn,
1293
+ depth: depth + 1,
1294
+ maxDepth
1280
1295
  };
1281
1296
  if (serializedNode.type === NodeType$1$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1282
1297
  else {
@@ -1331,7 +1346,9 @@ function serializeNodeWithId(n2, options) {
1331
1346
  iframeLoadTimeout,
1332
1347
  onStylesheetLoad,
1333
1348
  stylesheetLoadTimeout,
1334
- keepIframeSrcFn
1349
+ keepIframeSrcFn,
1350
+ depth: depth + 1,
1351
+ maxDepth
1335
1352
  });
1336
1353
  if (serializedIframeNode) {
1337
1354
  onIframeLoad(
@@ -1372,7 +1389,9 @@ function serializeNodeWithId(n2, options) {
1372
1389
  iframeLoadTimeout,
1373
1390
  onStylesheetLoad,
1374
1391
  stylesheetLoadTimeout,
1375
- keepIframeSrcFn
1392
+ keepIframeSrcFn,
1393
+ depth,
1394
+ maxDepth
1376
1395
  });
1377
1396
  if (serializedLinkNode) {
1378
1397
  onStylesheetLoad(
@@ -1408,7 +1427,8 @@ function snapshot(n2, options) {
1408
1427
  iframeLoadTimeout,
1409
1428
  onStylesheetLoad,
1410
1429
  stylesheetLoadTimeout,
1411
- keepIframeSrcFn = () => false
1430
+ keepIframeSrcFn = () => false,
1431
+ maxDepth
1412
1432
  } = options || {};
1413
1433
  const maskInputOptions = maskAllInputs === true ? {
1414
1434
  color: true,
@@ -1469,7 +1489,8 @@ function snapshot(n2, options) {
1469
1489
  onStylesheetLoad,
1470
1490
  stylesheetLoadTimeout,
1471
1491
  keepIframeSrcFn,
1472
- newlyAddedElement: false
1492
+ newlyAddedElement: false,
1493
+ maxDepth
1473
1494
  });
1474
1495
  }
1475
1496
  function getDefaultExportFromCjs$1(x) {