impeccable 2.3.2 → 3.0.1

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.
@@ -660,6 +660,7 @@ if (IS_BROWSER) {
660
660
  if (el.closest('.impeccable-overlay, .impeccable-label, .impeccable-banner, .impeccable-tooltip')) continue;
661
661
  if (el.closest('[id^="impeccable-live-"]')) continue;
662
662
  if (el === document.body || el === document.documentElement) continue;
663
+ if (!isRenderedForBrowserRule(el)) continue;
663
664
 
664
665
  const tag = el.tagName.toLowerCase();
665
666
  const style = getComputedStyle(el);
@@ -1091,6 +1092,7 @@ if (IS_BROWSER) {
1091
1092
  return { ...candidate, status: 'unresolved', confidence: 'none', reason: 'stale selector' };
1092
1093
  }
1093
1094
  if (!el) return { ...candidate, status: 'unresolved', confidence: 'none', reason: 'missing element' };
1095
+ if (!isRenderedForBrowserRule(el)) return { ...candidate, status: 'unresolved', confidence: 'none', reason: 'hidden element' };
1094
1096
 
1095
1097
  const blockingReason = (candidate.reasons || []).find(reason =>
1096
1098
  reason === 'background-clip text' ||
@@ -1437,13 +1439,20 @@ if (IS_BROWSER) {
1437
1439
  return true;
1438
1440
  }
1439
1441
 
1440
- function postSerializedFindings(groupMap) {
1442
+ function scanResultMeta(options = {}) {
1443
+ const scanId = options.scanId;
1444
+ if (typeof scanId !== 'string' && typeof scanId !== 'number') return {};
1445
+ return { scanId: String(scanId) };
1446
+ }
1447
+
1448
+ function postSerializedFindings(groupMap, options = {}) {
1441
1449
  if (!EXTENSION_MODE) return;
1442
1450
  const allFindings = browserFindingsFromMap(groupMap);
1443
1451
  window.postMessage({
1444
1452
  source: 'impeccable-results',
1445
1453
  findings: serializeFindings(allFindings),
1446
1454
  count: allFindings.length,
1455
+ ...scanResultMeta(options),
1447
1456
  }, '*');
1448
1457
  }
1449
1458
 
@@ -1497,7 +1506,7 @@ if (IS_BROWSER) {
1497
1506
  rememberVisualContrastAnalysis(result);
1498
1507
  const added = addVisualContrastResult(groupMap, result, { decorate: true });
1499
1508
  if (added) {
1500
- postSerializedFindings(groupMap);
1509
+ postSerializedFindings(groupMap, options);
1501
1510
  window.dispatchEvent(new CustomEvent('impeccable-visual-contrast-resolved', {
1502
1511
  detail: {
1503
1512
  selector: result.selector,
@@ -1565,7 +1574,7 @@ if (IS_BROWSER) {
1565
1574
  overlayIndex = 0;
1566
1575
  }
1567
1576
 
1568
- function renderBrowserFindings(collected) {
1577
+ function renderBrowserFindings(collected, options = {}) {
1569
1578
  const { allFindings, pageLevelFindings } = collected;
1570
1579
 
1571
1580
  for (const { el, findings } of allFindings) {
@@ -1585,6 +1594,7 @@ if (IS_BROWSER) {
1585
1594
  source: 'impeccable-results',
1586
1595
  findings: serializeFindings(allFindings),
1587
1596
  count: allFindings.length,
1597
+ ...scanResultMeta(options),
1588
1598
  }, '*');
1589
1599
  }
1590
1600
 
@@ -1599,11 +1609,11 @@ if (IS_BROWSER) {
1599
1609
  clearOverlays();
1600
1610
  const generation = scanGeneration;
1601
1611
  const collected = collectBrowserFindings();
1602
- const allFindings = renderBrowserFindings(collected);
1612
+ const allFindings = renderBrowserFindings(collected, options);
1603
1613
  if (shouldRunVisualContrast(options)) {
1604
1614
  addVisualContrastFindings(collected.groupMap, options, { decorate: true, generation })
1605
1615
  .then(() => {
1606
- if (generation === scanGeneration) postSerializedFindings(collected.groupMap);
1616
+ if (generation === scanGeneration) postSerializedFindings(collected.groupMap, options);
1607
1617
  })
1608
1618
  .catch(err => {
1609
1619
  reportVisualContrastError(err);
@@ -1618,10 +1628,10 @@ if (IS_BROWSER) {
1618
1628
  if (shouldRunVisualContrast(options)) {
1619
1629
  const collected = await collectBrowserFindingsAsync(options, { generation, scheduleLazy: true });
1620
1630
  if (generation !== scanGeneration) return [];
1621
- return renderBrowserFindings(collected);
1631
+ return renderBrowserFindings(collected, options);
1622
1632
  }
1623
1633
  lastVisualContrastAnalyses = [];
1624
- return renderBrowserFindings(collectBrowserFindings());
1634
+ return renderBrowserFindings(collectBrowserFindings(), options);
1625
1635
  };
1626
1636
 
1627
1637
  const detect = function(options = {}) {