@diegovelasquezweb/a11y-engine 0.11.42 → 0.11.43

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diegovelasquezweb/a11y-engine",
3
- "version": "0.11.42",
3
+ "version": "0.11.43",
4
4
  "description": "WCAG 2.2 accessibility audit engine — scanner, analyzer, and report builders",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -165,11 +165,23 @@ function buildPatternAiInput({ finding, candidate, projectHints }) {
165
165
  ? finding.context.split("\n").map((l) => l.trim()).filter(Boolean)
166
166
  : [];
167
167
  const matchPrefix = rawMatch.slice(0, 30);
168
- const contextAnchor = contextLines.reduce((best, line) => {
168
+ // The current content at the original line position — use this to pin the anchor
169
+ // to THIS specific element rather than a sibling with a similar match prefix.
170
+ const currentAtOriginal = effectiveLineIndex >= 0
171
+ ? (fileLines[effectiveLineIndex] || "").trim()
172
+ : "";
173
+ // Prefer a context line that exactly matches the current file content at originalLine.
174
+ // This disambiguates siblings (e.g. two inputs with placeholder=) when the file has
175
+ // not yet been modified. Falls back to the longest context line for post-shift cases
176
+ // where the original position now holds different content (lines were inserted before it).
177
+ const exactContextMatch = matchPrefix
178
+ ? contextLines.find((l) => l === currentAtOriginal && l.includes(matchPrefix)) || null
179
+ : null;
180
+ const longestContextMatch = contextLines.reduce((best, line) => {
169
181
  if (!matchPrefix || !line.includes(matchPrefix)) return best;
170
182
  return !best || line.length > best.length ? line : best;
171
183
  }, null);
172
- const anchor = contextAnchor || matchPrefix;
184
+ const anchor = exactContextMatch || longestContextMatch || matchPrefix;
173
185
 
174
186
  // The file may have been modified by a previous sequential fix (lines shifted).
175
187
  // Search for the actual current line containing the anchor instead of