@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.
package/dist/rrweb.cjs CHANGED
@@ -1148,6 +1148,8 @@ function slimDOMExcluded(sn, slimDOMOptions) {
1148
1148
  }
1149
1149
  return false;
1150
1150
  }
1151
+ const DEFAULT_MAX_DEPTH = 50;
1152
+ let _maxDepthWarned = false;
1151
1153
  function serializeNodeWithId(n2, options) {
1152
1154
  const {
1153
1155
  doc,
@@ -1171,10 +1173,21 @@ function serializeNodeWithId(n2, options) {
1171
1173
  onStylesheetLoad,
1172
1174
  stylesheetLoadTimeout = 5e3,
1173
1175
  keepIframeSrcFn = () => false,
1174
- newlyAddedElement = false
1176
+ newlyAddedElement = false,
1177
+ depth = 0,
1178
+ maxDepth = DEFAULT_MAX_DEPTH
1175
1179
  } = options;
1176
1180
  let { needsMask } = options;
1177
1181
  let { preserveWhiteSpace = true } = options;
1182
+ if (depth >= maxDepth) {
1183
+ if (!_maxDepthWarned) {
1184
+ _maxDepthWarned = true;
1185
+ console.warn(
1186
+ `[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.`
1187
+ );
1188
+ }
1189
+ return null;
1190
+ }
1178
1191
  if (!needsMask) {
1179
1192
  const checkAncestors = needsMask === void 0;
1180
1193
  needsMask = needMaskingText(
@@ -1255,7 +1268,9 @@ function serializeNodeWithId(n2, options) {
1255
1268
  iframeLoadTimeout,
1256
1269
  onStylesheetLoad,
1257
1270
  stylesheetLoadTimeout,
1258
- keepIframeSrcFn
1271
+ keepIframeSrcFn,
1272
+ depth: depth + 1,
1273
+ maxDepth
1259
1274
  };
1260
1275
  if (serializedNode.type === NodeType$1$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1261
1276
  else {
@@ -1310,7 +1325,9 @@ function serializeNodeWithId(n2, options) {
1310
1325
  iframeLoadTimeout,
1311
1326
  onStylesheetLoad,
1312
1327
  stylesheetLoadTimeout,
1313
- keepIframeSrcFn
1328
+ keepIframeSrcFn,
1329
+ depth: depth + 1,
1330
+ maxDepth
1314
1331
  });
1315
1332
  if (serializedIframeNode) {
1316
1333
  onIframeLoad(
@@ -1351,7 +1368,9 @@ function serializeNodeWithId(n2, options) {
1351
1368
  iframeLoadTimeout,
1352
1369
  onStylesheetLoad,
1353
1370
  stylesheetLoadTimeout,
1354
- keepIframeSrcFn
1371
+ keepIframeSrcFn,
1372
+ depth,
1373
+ maxDepth
1355
1374
  });
1356
1375
  if (serializedLinkNode) {
1357
1376
  onStylesheetLoad(
@@ -1387,7 +1406,8 @@ function snapshot(n2, options) {
1387
1406
  iframeLoadTimeout,
1388
1407
  onStylesheetLoad,
1389
1408
  stylesheetLoadTimeout,
1390
- keepIframeSrcFn = () => false
1409
+ keepIframeSrcFn = () => false,
1410
+ maxDepth
1391
1411
  } = options || {};
1392
1412
  const maskInputOptions = maskAllInputs === true ? {
1393
1413
  color: true,
@@ -1448,7 +1468,8 @@ function snapshot(n2, options) {
1448
1468
  onStylesheetLoad,
1449
1469
  stylesheetLoadTimeout,
1450
1470
  keepIframeSrcFn,
1451
- newlyAddedElement: false
1471
+ newlyAddedElement: false,
1472
+ maxDepth
1452
1473
  });
1453
1474
  }
1454
1475
  const MEDIA_SELECTOR = /(max|min)-device-(width|height)/;