releasebird-javascript-sdk 1.0.54 → 1.0.55

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.
@@ -381,10 +381,19 @@ export default class RbirdScreenshotManager {
381
381
  // Filter out images with external sources that might cause CORS issues
382
382
  if (node.tagName === 'IMG') {
383
383
  const src = node.getAttribute('src');
384
+
385
+ // Filter external images
384
386
  if (src && src.startsWith('http') && !src.includes(window.location.hostname)) {
385
387
  console.log('[Screenshot] Filtering out external image:', src);
386
388
  return false;
387
389
  }
390
+
391
+ // Filter broken or unloaded images
392
+ if (!node.complete || node.naturalWidth === 0) {
393
+ console.log('[Screenshot] Filtering out broken/unloaded image:', src);
394
+ return false;
395
+ }
396
+
388
397
  // Filter out large images
389
398
  try {
390
399
  const boundingRect = node.getBoundingClientRect();
@@ -393,7 +402,8 @@ export default class RbirdScreenshotManager {
393
402
  return false;
394
403
  }
395
404
  } catch (e) {
396
- // Continue if we can't get bounding rect
405
+ // If we can't get bounding rect, filter it out to be safe
406
+ return false;
397
407
  }
398
408
  }
399
409
  return true;
@@ -431,13 +441,31 @@ export default class RbirdScreenshotManager {
431
441
  const images = clonedDocument.querySelectorAll('img');
432
442
  images.forEach((img) => {
433
443
  const src = img.getAttribute('src');
444
+
445
+ // Remove external images
434
446
  if (src && src.startsWith('http') && !src.includes(window.location.hostname)) {
435
- // Remove external images completely to avoid CORS errors
436
447
  console.log('[Screenshot] Removing external image from clone:', src);
437
448
  img.remove();
438
- } else {
439
- img.crossOrigin = 'anonymous';
449
+ return;
440
450
  }
451
+
452
+ // Check if image is loaded and valid in the original document
453
+ try {
454
+ const originalImg = document.querySelector(`img[src="${src}"]`);
455
+ if (originalImg && (!originalImg.complete || originalImg.naturalWidth === 0)) {
456
+ console.log('[Screenshot] Removing broken/unloaded image:', src);
457
+ img.remove();
458
+ return;
459
+ }
460
+ } catch (e) {
461
+ // If we can't check, remove to be safe
462
+ console.log('[Screenshot] Removing image due to check error:', src);
463
+ img.remove();
464
+ return;
465
+ }
466
+
467
+ // Set crossOrigin for remaining images
468
+ img.crossOrigin = 'anonymous';
441
469
  });
442
470
 
443
471
  // Remove large SVGs and Canvas elements from clone