pour-engine 1.1.7 → 1.1.8

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.
@@ -6,6 +6,6 @@
6
6
  export default {
7
7
  engine: {
8
8
  name: 'pour engine',
9
- version: '1.1.7',
9
+ version: '1.1.8',
10
10
  },
11
11
  };
@@ -38,6 +38,17 @@ function isHiddenFromPointer(element, rect) {
38
38
  return false;
39
39
  }
40
40
 
41
+ /** Text this element contributes that is NOT inside a target — i.e. does it
42
+ * read as prose beside the link, or is it just another control in a list? */
43
+ function textOutsideTargets(element) {
44
+ for (const node of element.childNodes) {
45
+ if (node.nodeType === Node.TEXT_NODE && node.textContent.trim()) return true;
46
+ if (node.nodeType === Node.ELEMENT_NODE && !node.matches(TARGETS)
47
+ && textOutsideTargets(node)) return true;
48
+ }
49
+ return false;
50
+ }
51
+
41
52
  function isInTextLine(element) {
42
53
  let node = element;
43
54
  // inline-block/inline-flex links inside a sentence are still "in a line
@@ -48,9 +59,17 @@ function isInTextLine(element) {
48
59
  for (const sibling of node.parentNode?.childNodes ?? []) {
49
60
  if (sibling === node) continue;
50
61
  if (sibling.nodeType === Node.TEXT_NODE && sibling.textContent.trim()) return true;
62
+ // What counts is text the sibling contributes OUTSIDE any target, not
63
+ // merely that the sibling isn't a target itself. Testing identity alone
64
+ // let a list of links exempt itself — each <li> is not an anchor, so a
65
+ // sibling <li><a>t</a></li> read as prose and granted the exception to
66
+ // the whole cluster, exactly the nav list this function's contract says
67
+ // to exclude (Wikipedia's "v · t · e" navbox slipped through there).
68
+ // Testing `querySelector(TARGETS)` instead over-corrects the other way:
69
+ // a prose wrapper containing a link is still prose.
51
70
  if (sibling.nodeType === Node.ELEMENT_NODE
52
71
  && !sibling.matches(TARGETS)
53
- && sibling.textContent.trim()
72
+ && textOutsideTargets(sibling)
54
73
  && getComputedStyle(sibling).display.startsWith('inline')) return true;
55
74
  }
56
75
  node = node.parentElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pour-engine",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "description": "Accessibility (WCAG 2.2) audit engine written from the W3C specifications — runs entirely in the browser, no dependencies.",
5
5
  "type": "module",
6
6
  "main": "engine/index.js",