@posthog/rrweb-record 0.0.40 → 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.
@@ -1136,6 +1136,8 @@ function slimDOMExcluded(sn, slimDOMOptions) {
1136
1136
  }
1137
1137
  return false;
1138
1138
  }
1139
+ const DEFAULT_MAX_DEPTH = 50;
1140
+ let _maxDepthWarned = false;
1139
1141
  function serializeNodeWithId(n2, options) {
1140
1142
  const {
1141
1143
  doc,
@@ -1159,10 +1161,21 @@ function serializeNodeWithId(n2, options) {
1159
1161
  onStylesheetLoad,
1160
1162
  stylesheetLoadTimeout = 5e3,
1161
1163
  keepIframeSrcFn = () => false,
1162
- newlyAddedElement = false
1164
+ newlyAddedElement = false,
1165
+ depth = 0,
1166
+ maxDepth = DEFAULT_MAX_DEPTH
1163
1167
  } = options;
1164
1168
  let { needsMask } = options;
1165
1169
  let { preserveWhiteSpace = true } = options;
1170
+ if (depth >= maxDepth) {
1171
+ if (!_maxDepthWarned) {
1172
+ _maxDepthWarned = true;
1173
+ console.warn(
1174
+ `[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.`
1175
+ );
1176
+ }
1177
+ return null;
1178
+ }
1166
1179
  if (!needsMask) {
1167
1180
  const checkAncestors = needsMask === void 0;
1168
1181
  needsMask = needMaskingText(
@@ -1243,7 +1256,9 @@ function serializeNodeWithId(n2, options) {
1243
1256
  iframeLoadTimeout,
1244
1257
  onStylesheetLoad,
1245
1258
  stylesheetLoadTimeout,
1246
- keepIframeSrcFn
1259
+ keepIframeSrcFn,
1260
+ depth: depth + 1,
1261
+ maxDepth
1247
1262
  };
1248
1263
  if (serializedNode.type === NodeType$1$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1249
1264
  else {
@@ -1298,7 +1313,9 @@ function serializeNodeWithId(n2, options) {
1298
1313
  iframeLoadTimeout,
1299
1314
  onStylesheetLoad,
1300
1315
  stylesheetLoadTimeout,
1301
- keepIframeSrcFn
1316
+ keepIframeSrcFn,
1317
+ depth: depth + 1,
1318
+ maxDepth
1302
1319
  });
1303
1320
  if (serializedIframeNode) {
1304
1321
  onIframeLoad(
@@ -1339,7 +1356,9 @@ function serializeNodeWithId(n2, options) {
1339
1356
  iframeLoadTimeout,
1340
1357
  onStylesheetLoad,
1341
1358
  stylesheetLoadTimeout,
1342
- keepIframeSrcFn
1359
+ keepIframeSrcFn,
1360
+ depth,
1361
+ maxDepth
1343
1362
  });
1344
1363
  if (serializedLinkNode) {
1345
1364
  onStylesheetLoad(
@@ -1375,7 +1394,8 @@ function snapshot(n2, options) {
1375
1394
  iframeLoadTimeout,
1376
1395
  onStylesheetLoad,
1377
1396
  stylesheetLoadTimeout,
1378
- keepIframeSrcFn = () => false
1397
+ keepIframeSrcFn = () => false,
1398
+ maxDepth
1379
1399
  } = options || {};
1380
1400
  const maskInputOptions = maskAllInputs === true ? {
1381
1401
  color: true,
@@ -1436,7 +1456,8 @@ function snapshot(n2, options) {
1436
1456
  onStylesheetLoad,
1437
1457
  stylesheetLoadTimeout,
1438
1458
  keepIframeSrcFn,
1439
- newlyAddedElement: false
1459
+ newlyAddedElement: false,
1460
+ maxDepth
1440
1461
  });
1441
1462
  }
1442
1463
  function getDefaultExportFromCjs$1(x) {