@posthog/rrweb 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.
@@ -1181,6 +1181,8 @@ function slimDOMExcluded(sn, slimDOMOptions) {
1181
1181
  }
1182
1182
  return false;
1183
1183
  }
1184
+ const DEFAULT_MAX_DEPTH = 50;
1185
+ let _maxDepthWarned = false;
1184
1186
  function serializeNodeWithId(n2, options) {
1185
1187
  const {
1186
1188
  doc,
@@ -1204,10 +1206,21 @@ function serializeNodeWithId(n2, options) {
1204
1206
  onStylesheetLoad,
1205
1207
  stylesheetLoadTimeout = 5e3,
1206
1208
  keepIframeSrcFn = () => false,
1207
- newlyAddedElement = false
1209
+ newlyAddedElement = false,
1210
+ depth = 0,
1211
+ maxDepth = DEFAULT_MAX_DEPTH
1208
1212
  } = options;
1209
1213
  let { needsMask } = options;
1210
1214
  let { preserveWhiteSpace = true } = options;
1215
+ if (depth >= maxDepth) {
1216
+ if (!_maxDepthWarned) {
1217
+ _maxDepthWarned = true;
1218
+ console.warn(
1219
+ `[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.`
1220
+ );
1221
+ }
1222
+ return null;
1223
+ }
1211
1224
  if (!needsMask) {
1212
1225
  const checkAncestors = needsMask === void 0;
1213
1226
  needsMask = needMaskingText(
@@ -1288,7 +1301,9 @@ function serializeNodeWithId(n2, options) {
1288
1301
  iframeLoadTimeout,
1289
1302
  onStylesheetLoad,
1290
1303
  stylesheetLoadTimeout,
1291
- keepIframeSrcFn
1304
+ keepIframeSrcFn,
1305
+ depth: depth + 1,
1306
+ maxDepth
1292
1307
  };
1293
1308
  if (serializedNode.type === NodeType$1$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1294
1309
  else {
@@ -1343,7 +1358,9 @@ function serializeNodeWithId(n2, options) {
1343
1358
  iframeLoadTimeout,
1344
1359
  onStylesheetLoad,
1345
1360
  stylesheetLoadTimeout,
1346
- keepIframeSrcFn
1361
+ keepIframeSrcFn,
1362
+ depth: depth + 1,
1363
+ maxDepth
1347
1364
  });
1348
1365
  if (serializedIframeNode) {
1349
1366
  onIframeLoad(
@@ -1384,7 +1401,9 @@ function serializeNodeWithId(n2, options) {
1384
1401
  iframeLoadTimeout,
1385
1402
  onStylesheetLoad,
1386
1403
  stylesheetLoadTimeout,
1387
- keepIframeSrcFn
1404
+ keepIframeSrcFn,
1405
+ depth,
1406
+ maxDepth
1388
1407
  });
1389
1408
  if (serializedLinkNode) {
1390
1409
  onStylesheetLoad(
@@ -1420,7 +1439,8 @@ function snapshot(n2, options) {
1420
1439
  iframeLoadTimeout,
1421
1440
  onStylesheetLoad,
1422
1441
  stylesheetLoadTimeout,
1423
- keepIframeSrcFn = () => false
1442
+ keepIframeSrcFn = () => false,
1443
+ maxDepth
1424
1444
  } = options || {};
1425
1445
  const maskInputOptions = maskAllInputs === true ? {
1426
1446
  color: true,
@@ -1481,7 +1501,8 @@ function snapshot(n2, options) {
1481
1501
  onStylesheetLoad,
1482
1502
  stylesheetLoadTimeout,
1483
1503
  keepIframeSrcFn,
1484
- newlyAddedElement: false
1504
+ newlyAddedElement: false,
1505
+ maxDepth
1485
1506
  });
1486
1507
  }
1487
1508
  const MEDIA_SELECTOR = /(max|min)-device-(width|height)/;