@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.js CHANGED
@@ -1146,6 +1146,8 @@ function slimDOMExcluded(sn, slimDOMOptions) {
1146
1146
  }
1147
1147
  return false;
1148
1148
  }
1149
+ const DEFAULT_MAX_DEPTH = 50;
1150
+ let _maxDepthWarned = false;
1149
1151
  function serializeNodeWithId(n2, options) {
1150
1152
  const {
1151
1153
  doc,
@@ -1169,10 +1171,21 @@ function serializeNodeWithId(n2, options) {
1169
1171
  onStylesheetLoad,
1170
1172
  stylesheetLoadTimeout = 5e3,
1171
1173
  keepIframeSrcFn = () => false,
1172
- newlyAddedElement = false
1174
+ newlyAddedElement = false,
1175
+ depth = 0,
1176
+ maxDepth = DEFAULT_MAX_DEPTH
1173
1177
  } = options;
1174
1178
  let { needsMask } = options;
1175
1179
  let { preserveWhiteSpace = true } = options;
1180
+ if (depth >= maxDepth) {
1181
+ if (!_maxDepthWarned) {
1182
+ _maxDepthWarned = true;
1183
+ console.warn(
1184
+ `[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.`
1185
+ );
1186
+ }
1187
+ return null;
1188
+ }
1176
1189
  if (!needsMask) {
1177
1190
  const checkAncestors = needsMask === void 0;
1178
1191
  needsMask = needMaskingText(
@@ -1253,7 +1266,9 @@ function serializeNodeWithId(n2, options) {
1253
1266
  iframeLoadTimeout,
1254
1267
  onStylesheetLoad,
1255
1268
  stylesheetLoadTimeout,
1256
- keepIframeSrcFn
1269
+ keepIframeSrcFn,
1270
+ depth: depth + 1,
1271
+ maxDepth
1257
1272
  };
1258
1273
  if (serializedNode.type === NodeType$1$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1259
1274
  else {
@@ -1308,7 +1323,9 @@ function serializeNodeWithId(n2, options) {
1308
1323
  iframeLoadTimeout,
1309
1324
  onStylesheetLoad,
1310
1325
  stylesheetLoadTimeout,
1311
- keepIframeSrcFn
1326
+ keepIframeSrcFn,
1327
+ depth: depth + 1,
1328
+ maxDepth
1312
1329
  });
1313
1330
  if (serializedIframeNode) {
1314
1331
  onIframeLoad(
@@ -1349,7 +1366,9 @@ function serializeNodeWithId(n2, options) {
1349
1366
  iframeLoadTimeout,
1350
1367
  onStylesheetLoad,
1351
1368
  stylesheetLoadTimeout,
1352
- keepIframeSrcFn
1369
+ keepIframeSrcFn,
1370
+ depth,
1371
+ maxDepth
1353
1372
  });
1354
1373
  if (serializedLinkNode) {
1355
1374
  onStylesheetLoad(
@@ -1385,7 +1404,8 @@ function snapshot(n2, options) {
1385
1404
  iframeLoadTimeout,
1386
1405
  onStylesheetLoad,
1387
1406
  stylesheetLoadTimeout,
1388
- keepIframeSrcFn = () => false
1407
+ keepIframeSrcFn = () => false,
1408
+ maxDepth
1389
1409
  } = options || {};
1390
1410
  const maskInputOptions = maskAllInputs === true ? {
1391
1411
  color: true,
@@ -1446,7 +1466,8 @@ function snapshot(n2, options) {
1446
1466
  onStylesheetLoad,
1447
1467
  stylesheetLoadTimeout,
1448
1468
  keepIframeSrcFn,
1449
- newlyAddedElement: false
1469
+ newlyAddedElement: false,
1470
+ maxDepth
1450
1471
  });
1451
1472
  }
1452
1473
  const MEDIA_SELECTOR = /(max|min)-device-(width|height)/;