@diegovelasquezweb/a11y-engine 0.11.41 → 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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diegovelasquezweb/a11y-engine",
3
- "version": "0.11.41",
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",
@@ -32,9 +32,6 @@
32
32
  "CHANGELOG.md",
33
33
  "LICENSE"
34
34
  ],
35
- "scripts": {
36
- "test": "vitest run"
37
- },
38
35
  "dependencies": {
39
36
  "@axe-core/playwright": "^4.11.1",
40
37
  "axe-core": "^4.11.1",
@@ -44,5 +41,7 @@
44
41
  "devDependencies": {
45
42
  "vitest": "^4.0.18"
46
43
  },
47
- "packageManager": "pnpm@10.22.0+sha512.bf049efe995b28f527fd2b41ae0474ce29186f7edcb3bf545087bd61fbbebb2bf75362d1307fda09c2d288e1e499787ac12d4fcb617a974718a6051f2eee741c"
48
- }
44
+ "scripts": {
45
+ "test": "vitest run"
46
+ }
47
+ }
File without changes
@@ -157,14 +157,40 @@ function buildPatternAiInput({ finding, candidate, projectHints }) {
157
157
  const originalLine = typeof finding.line === "number" ? finding.line : null;
158
158
  const rawMatch = typeof finding.match === "string" ? finding.match.trim() : "";
159
159
 
160
+ // rawMatch is often just the regex prefix (e.g. 'placeholder="') and is not unique
161
+ // when multiple elements match the same pattern in the same file.
162
+ // Use finding.context to build a more specific anchor so sequential fixes on the
163
+ // same file don't end up targeting an already-patched sibling element.
164
+ const contextLines = typeof finding.context === "string"
165
+ ? finding.context.split("\n").map((l) => l.trim()).filter(Boolean)
166
+ : [];
167
+ const matchPrefix = rawMatch.slice(0, 30);
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) => {
181
+ if (!matchPrefix || !line.includes(matchPrefix)) return best;
182
+ return !best || line.length > best.length ? line : best;
183
+ }, null);
184
+ const anchor = exactContextMatch || longestContextMatch || matchPrefix;
185
+
160
186
  // The file may have been modified by a previous sequential fix (lines shifted).
161
- // Search for the actual current line containing the match string instead of
187
+ // Search for the actual current line containing the anchor instead of
162
188
  // relying solely on the original line number from the scan.
163
189
  let effectiveLineIndex = originalLine !== null ? originalLine - 1 : -1;
164
- if (rawMatch && effectiveLineIndex >= 0) {
190
+ if (anchor && effectiveLineIndex >= 0) {
165
191
  const lineAtOriginal = (fileLines[effectiveLineIndex] || "").trim();
166
- if (!lineAtOriginal.includes(rawMatch.slice(0, 30))) {
167
- const found = fileLines.findIndex((l) => l.trim().includes(rawMatch.slice(0, 30)));
192
+ if (!lineAtOriginal.includes(anchor)) {
193
+ const found = fileLines.findIndex((l) => l.trim().includes(anchor));
168
194
  if (found !== -1) effectiveLineIndex = found;
169
195
  }
170
196
  }
File without changes
File without changes