@kinti/a11y-toolkit 5.28.0 → 5.29.0

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.
@@ -237,6 +237,7 @@ CRIT = {
237
237
  '3.2.6': '3.2.6 Ayuda coherente',
238
238
  '1.4.5': '1.4.5 Imágenes de texto',
239
239
  '1.4.11': '1.4.11 Contraste no textual',
240
+ '1.4.12': '1.4.12 Espaciado de texto',
240
241
  '1.4.13': '1.4.13 Contenido al pasar el foco o el puntero',
241
242
  '3.3.3': '3.3.3 Sugerencia ante errores',
242
243
  '1.4.2': '1.4.2 Control del audio',
@@ -293,6 +294,7 @@ CRIT = {
293
294
  '3.2.6': '3.2.6 Consistent Help',
294
295
  '1.4.5': '1.4.5 Images of Text',
295
296
  '1.4.11': '1.4.11 Non-text Contrast',
297
+ '1.4.12': '1.4.12 Text Spacing',
296
298
  '1.4.13': '1.4.13 Content on Hover or Focus',
297
299
  '3.3.3': '3.3.3 Error Suggestion',
298
300
  '1.4.2': '1.4.2 Audio Control',
@@ -343,6 +345,11 @@ _OVERLAY_WIDGETS = (
343
345
  ('Recite Me', ('recite.me',)),
344
346
  ('User1st', ('user1st.com',)),
345
347
  ('UsableNet', ('usablenet.com',)),
348
+ # ronda 18-nov contra overlayfactsheet.com (46 productos nombrados allí;
349
+ # solo entran dominios verificados contra la web oficial de cada vendedor)
350
+ ('Eye-Able', ('eye-able.com',)),
351
+ ('AccessiWay', ('accessiway.com',)),
352
+ ('Equally AI', ('equally.ai',)),
346
353
  )
347
354
 
348
355
  # texto de un skip link (es/en/pt/fr — el vocabulario del patrón 3e12e1)
@@ -510,6 +517,8 @@ class _Auditor(HTMLParser):
510
517
  self.missing_autocomplete = []
511
518
  self.autocomplete_invalid = []
512
519
  self.autocomplete_mismatch = []
520
+ self.heading_role_removed = [] # h1-h6 con rol que sustituye al de heading
521
+ self.text_spacing_important = [] # 1.4.12: spacing !important inline (ACT 24afc2/78fd32/9e45ec)
513
522
  self.links = {} # nombre normalizado → set de hrefs
514
523
  self.generics = 0
515
524
  self.labels_for_dups = {} # id → n labels (los >1, varios)
@@ -1056,6 +1065,16 @@ class _Auditor(HTMLParser):
1056
1065
  style = a.get('style') or ''
1057
1066
  if 'animation' in style and 'infinite' in style:
1058
1067
  self.mobiles.append(f'{tag}[style animation…infinite]')
1068
+ # 1.4.12 text spacing (ACT 24afc2/78fd32/9e45ec): un !important en
1069
+ # line/letter/word-spacing inline impide al usuario re-espaciar el
1070
+ # texto con su hoja de estilos — fallo mecánico, cero ambigüedad
1071
+ if not self._in_template:
1072
+ _sp = re.search(
1073
+ r'(letter|word)-spacing\s*:[^;"}]*!important|'
1074
+ r'line-height\s*:[^;"}]*!important', style, re.I)
1075
+ if _sp and len(self.text_spacing_important) < 12:
1076
+ self.text_spacing_important.append(
1077
+ f'{tag}[{_sp.group(0)[:34]}]')
1059
1078
  # v3.12: 2.5.1 gesture without click alternative (attribute-level hint)
1060
1079
  if a.get('ontouchmove') or a.get('ondrag'):
1061
1080
  if not (a.get('onclick') or tag in ('input', 'button', 'a')):
@@ -1239,9 +1258,17 @@ class _Auditor(HTMLParser):
1239
1258
  if tag in ('h1', 'h2', 'h3', 'h4', 'h5', 'h6'):
1240
1259
  # role=none/presentation APAGA la semántica del encabezado; un
1241
1260
  # aria-level válido la SOBRESCRIBE (accname: h3[aria-level=4] ES 4)
1242
- if (a.get('role') or '').strip().lower() in ('none', 'presentation') \
1243
- or self._in_template:
1261
+ _hrole = (a.get('role') or '').strip().lower()
1262
+ if _hrole in ('none', 'presentation') or self._in_template:
1244
1263
  pass
1264
+ elif _hrole and _hrole != 'heading':
1265
+ # CUALQUIER otro rol explícito SUSTITUYE al de heading (la
1266
+ # primera regla de ARIA): h2 role=button desaparece de la
1267
+ # navegación por encabezados del AT — se registra (1.3.1)
1268
+ if not _hidden and len(self.heading_role_removed) < 12:
1269
+ _nm = (a.get('aria-label') or '').strip()[:24]
1270
+ self.heading_role_removed.append(
1271
+ f'{tag} role="{_hrole}"' + (f' "{_nm}"' if _nm else ''))
1245
1272
  else:
1246
1273
  self._heading_level = int(tag[1])
1247
1274
  _alv = re.match(r'\d+', str(a.get('aria-level') or ''))
@@ -2077,6 +2104,12 @@ def audit_html(html_text, url='(html)', lang='en', standard=None, target=None):
2077
2104
  add('low', '1.3.1', 'no_headings')
2078
2105
  if p.empty_h:
2079
2106
  add('low', '1.3.1', 'empty_heading', n=p.empty_h)
2107
+ if p.heading_role_removed:
2108
+ add_ej('medium', '1.3.1', 'heading_role_removed', p.heading_role_removed,
2109
+ n=len(p.heading_role_removed), example=', '.join(p.heading_role_removed[:4]))
2110
+ if p.text_spacing_important:
2111
+ add_ej('medium', '1.4.12', 'text_spacing_important', p.text_spacing_important,
2112
+ n=len(p.text_spacing_important), example=', '.join(p.text_spacing_important[:4]))
2080
2113
  if p.tables and p.tables_with_th < p.tables:
2081
2114
  add('medium', '1.3.1', 'table_no_th', n=p.tables - p.tables_with_th,
2082
2115
  paths=[p._elem_paths[id(_a)] for _a in p.tables_no_th_elems
@@ -908,6 +908,8 @@ _SIGNAL_CRIT = {
908
908
  'skip_target_hidden': '2.4.1',
909
909
  'placeholder_contrast': '1.4.3',
910
910
  'autocomplete_mismatch': '1.3.5',
911
+ 'heading_role_removed': '1.3.1',
912
+ 'text_spacing_important': '1.4.12',
911
913
  'label_in_name': '2.5.3',
912
914
  'label_orphan': '3.3.2',
913
915
  'label_vague': '2.4.6',
@@ -988,6 +988,36 @@ _JS_FORM_STATE = r'''(pre) => {
988
988
  return out;
989
989
  }'''
990
990
 
991
+ # 18-nov: label→foco. Click en un <label> asociado debe enfocar su campo:
992
+ # es comportamiento nativo del spec, así que si falla solo puede ser JS
993
+ # saboteándolo (preventDefault de date-pickers y amigos). DATO, no hallazgo:
994
+ # hasta calibrar la prevalencia real, la honesty manda (filter, not verdict).
995
+ _JS_LABEL_FOCUS = r'''() => {
996
+ const out = {checked: 0, failures: []};
997
+ for (const lb of document.querySelectorAll('label')) {
998
+ if (out.checked >= 8) break;
999
+ const ctl = lb.control
1000
+ || (lb.getAttribute('for') ? document.getElementById(lb.getAttribute('for')) : null);
1001
+ if (!ctl) continue;
1002
+ const tag = ctl.tagName.toLowerCase();
1003
+ const type = (ctl.getAttribute('type') || '').toLowerCase();
1004
+ if (tag === 'button' || tag === 'a'
1005
+ || (tag === 'input' && ['submit', 'button', 'reset', 'image'].includes(type)))
1006
+ continue; // click podría ENVIAR: fuera del alcance
1007
+ if (ctl.disabled) continue;
1008
+ if (!ctl.offsetParent && getComputedStyle(ctl).display === 'none'
1009
+ && getComputedStyle(ctl).visibility === 'hidden') continue;
1010
+ out.checked++;
1011
+ const sel = 'label' + (lb.htmlFor ? '[for="' + lb.htmlFor + '"]' : ':nth-of-type(1)');
1012
+ lb.click();
1013
+ const ae = document.activeElement;
1014
+ if (!(ae === ctl || (ae && ctl.contains(ae))))
1015
+ out.failures.push(sel + ' → ' + tag + (type ? '[type=' + type + ']' : ''));
1016
+ try { ctl.blur(); } catch (e) {}
1017
+ }
1018
+ return out;
1019
+ }'''
1020
+
991
1021
  def audit_forms(url, timeout=45, lang='en', auth_state=None, browser='auto'):
992
1022
  """3.3.1 Error Identification / 3.3.3 Error Suggestion — the guided flow:
993
1023
  fill every validatable field with INVALID data, really submit, then judge
@@ -1005,6 +1035,10 @@ def audit_forms(url, timeout=45, lang='en', auth_state=None, browser='auto'):
1005
1035
  return {'error': _t(lang, 'fetch_error').format(e=e)}
1006
1036
  url_before = page.url
1007
1037
  pre = page.evaluate(_JS_FORM_PRE)
1038
+ try:
1039
+ label_focus = page.evaluate(_JS_LABEL_FOCUS)
1040
+ except Exception: # noqa: BLE001 — página hostil: sin dato, sin excusa
1041
+ label_focus = {'checked': 0, 'failures': []}
1008
1042
  touched = page.evaluate(_JS_FORM_FILL)
1009
1043
  page.wait_for_timeout(900)
1010
1044
  navigated = page.url.split('#')[0] != url_before.split('#')[0]
@@ -1035,12 +1069,13 @@ def audit_forms(url, timeout=45, lang='en', auth_state=None, browser='auto'):
1035
1069
  return {
1036
1070
  'url': url, 'mode': 'forms',
1037
1071
  'invalid_fields': len(touched),
1072
+ 'label_focus': label_focus,
1038
1073
  'detail': touched[:10],
1039
1074
  'score': compute_score(findings),
1040
1075
  'summary': {s_: sum(1 for h in findings if h['severity'] == s_)
1041
1076
  for s_ in ('high', 'medium', 'low')},
1042
1077
  'findings': findings,
1043
- 'limits': _t(lang, 'limits'),
1078
+ 'limits': _t(lang, 'limits') + ' ' + _t(lang, 'label_focus_note'),
1044
1079
  }
1045
1080
 
1046
1081
 
@@ -27,6 +27,10 @@
27
27
  "autocomplete_invalid_rem": "Use standard tokens: email, tel, name, postal-code, one-time-code… (full list in the tool).",
28
28
  "autocomplete_mismatch": "{n} fields with purpose contradicted between type and autocomplete: {example}. The browser cannot decide the purpose (1.3.5).",
29
29
  "autocomplete_mismatch_rem": "For humans, don't make me think; for machines, don't make me guess: type and token must say the same thing. type=email takes an email-family token (email, username); type=tel, the tel family; type=url, url.",
30
+ "heading_role_removed": "{n} headings overridden by another role: {example}. An explicit role replaces the heading role and the heading vanishes from screen reader heading navigation (1.3.1; 71.6% navigate by headings first, WebAIM SR Survey 10).",
31
+ "heading_role_removed_rem": "The correct pattern for an interactive heading is the control INSIDE: <h2><button>…</button></h2> keeps both heading and button; on the element itself, only use role=heading if that is its real function.",
32
+ "text_spacing_important": "{n} inline styles with letter/line/word-spacing set to !important: {example}. The user cannot re-space the text with their own stylesheet (1.4.12, ACT rules 24afc2/78fd32/9e45ec).",
33
+ "text_spacing_important_rem": "Drop the !important from inline spacing (normal specificity is enough): 1.4.12 requires users be able to raise line height to 1.5x and letter/word spacing without losing content.",
30
34
  "autocomplete_rem": "Add autocomplete with the right token (email, tel, name, postal-code…, 1.3.5): free accessibility and autofill at zero cost.",
31
35
  "blank_no_warning": "{n} links with target=\"_blank\" that do not warn they open a new window.",
32
36
  "blank_no_warning_rem": "Add a text hint (or title/aria-label): \"(opens in a new window)\", or let the user decide.",
@@ -317,6 +321,7 @@
317
321
  "skip_target_hidden_rem": "A bypass mechanism must land on perceivable content (2.4.1): point the link at visible content, or have the page reveal or expand the target on activation (hashchange or click), and give the target tabindex=\"-1\" so focus follows.",
318
322
  "placeholder_contrast": "{n} placeholders with insufficient contrast: {det}. The placeholder is text low-vision users must read, and 1.4.3 does not distinguish pseudo-elements (4.5:1, or 3:1 large text).",
319
323
  "placeholder_contrast_rem": "Give the placeholder its own color at ≥4.5:1 against the field background (the browser default gray sits at the minimum and fails on non-white backgrounds). Safe recipe: same color as the field text with opacity 0.7.",
324
+ "label_focus_note": "Label→focus: each associated <label> is clicked and its field checked to receive focus (data; the behavior is spec-native, its failure points to JS sabotaging it).",
320
325
  "limits": "Rendered audit: honest heuristics, no substitute for a screen reader or manual review. Contrast computed over computed backgrounds; cases with background images are reported as \"review\". 2.5.8 allows exceptions (equivalent inline, spacing) approximated here.",
321
326
  "reduced_motion_ignored": "{n} looping animations still run with prefers-reduced-motion set (before {n}, after {nr}): the user's preference is ignored (2.2.2).",
322
327
  "reduced_motion_ignored_rem": "Wrap animations in @media (prefers-reduced-motion: reduce) { animation: none } — or pause via the Animation API. The user asked for less motion; honor it.",
@@ -27,6 +27,10 @@
27
27
  "autocomplete_invalid_rem": "Usa tokens del estándar: email, tel, name, postal-code, one-time-code… (lista completa en la herramienta).",
28
28
  "autocomplete_mismatch": "{n} campos con propósito contradicho entre type y autocomplete: {example}. El navegador no puede decidir el propósito (1.3.5).",
29
29
  "autocomplete_mismatch_rem": "Para humanos, don't make me think; para máquinas, don't make me guess: el type y el token han de decir lo mismo. type=email lleva autocomplete de familia email (email, username); type=tel, familia tel; type=url, url.",
30
+ "heading_role_removed": "{n} encabezados anulados por otro rol: {example}. Un rol explícito sustituye al de heading y el encabezado desaparece de la navegación por encabezados del lector (1.3.1; el 71,6% navega primero por encabezados, WebAIM SR Survey 10).",
31
+ "heading_role_removed_rem": "El patrón correcto para un encabezado interactivo es el control DENTRO: <h2><button>…</button></h2> conserva encabezado y botón; sobre el elemento, usa role=heading solo si es su función real.",
32
+ "text_spacing_important": "{n} estilos inline con letter/line/word-spacing en !important: {example}. El usuario no puede re-espaciar el texto con su hoja de estilos (1.4.12, reglas ACT 24afc2/78fd32/9e45ec).",
33
+ "text_spacing_important_rem": "Quita el !important de los spacing inline (la especificidad normal basta): 1.4.12 exige que el usuario pueda aumentar el interlineado a 1,5 veces y los espaciados sin perder contenido.",
30
34
  "autocomplete_rem": "Añade autocomplete con el token correcto (email, tel, name, postal-code…, 1.3.5): relleno automático y voz de accesibilidad con sobrecoste cero.",
31
35
  "blank_no_warning": "{n} enlaces con target=\"_blank\" sin avisar de que abren ventana nueva.",
32
36
  "blank_no_warning_rem": "Añade aviso en texto (o title/aria-label): «(abre en ventana nueva)», o deja que la persona usuaria decida.",
@@ -317,6 +321,7 @@
317
321
  "skip_target_hidden_rem": "Un mecanismo de bypass debe aterrizar en contenido perceivable (2.4.1): apunta el enlace a contenido visible, o haz que la página revele o expanda el destino al activarlo (hashchange o click), y dale tabindex=\"-1\" al destino para que el foco lo acompañe.",
318
322
  "placeholder_contrast": "{n} placeholders con contraste insuficiente: {det}. El placeholder es texto que la gente con visión baja tiene que leer, y 1.4.3 no distingue pseudo-elementos (4.5:1, o 3:1 en texto grande).",
319
323
  "placeholder_contrast_rem": "Dale color propio al placeholder con contraste ≥4.5:1 sobre el fondo del campo (el gris por defecto del navegador roza el mínimo y falla sobre fondos no blancos). Ejemplo seguro: color igual al texto del campo pero con opacity 0.7.",
324
+ "label_focus_note": "Label→foco: se pulsa cada <label> asociado y se comprueba que su campo reciba el foco (dato; el comportamiento es del spec y su fallo apunta a JS que lo sabotea).",
320
325
  "limits": "Auditoría renderizada: heurística honesta, no sustituye lector de pantalla ni revisión manual. Contraste calculado sobre fondos computados; los casos con imagen de fondo se reportan como «revisar». 2.5.8 admite excepciones (inline equivalente, espaciado) que aquí se aproximan.",
321
326
  "reduced_motion_ignored": "{n} animaciones en bucle siguen moviéndose con prefers-reduced-motion activo (antes {n}, ahora {nr}): la preferencia del usuario se ignora (2.2.2).",
322
327
  "reduced_motion_ignored_rem": "Envuelve las animaciones en @media (prefers-reduced-motion: reduce) { animation: none } — o paúsala con la API Animation. El usuario pidió menos movimiento; respóndelo.",
@@ -97,7 +97,7 @@ try:
97
97
  except ImportError:
98
98
  ARIALIVE_JS = None # repo checkout: read the file
99
99
 
100
- VERSION = '5.28.0'
100
+ VERSION = '5.29.0'
101
101
 
102
102
  # Params renombrados a inglés en 5.11.0; se aceptan los nombres previos.
103
103
  PARAM_ALIASES = {
@@ -147,7 +147,10 @@ TOOLS = [
147
147
  'captions (1.2.2), autoplay audio (1.4.2), generic/duplicated link text '
148
148
  '(2.4.4), target=_blank without warning (3.2.5), positive tabindex '
149
149
  '(2.4.3), aria-hidden on focusable elements, tables without th, '
150
- 'duplicate ids, duplicate accesskeys. Each finding includes concrete '
150
+ 'duplicate ids, duplicate accesskeys, headings overridden by another '
151
+ 'role (1.3.1), letter/line/word-spacing !important inline (1.4.12, '
152
+ 'ACT 24afc2/78fd32/9e45ec), autocomplete purpose contradicting the '
153
+ 'field type (1.3.5). Each finding includes concrete '
151
154
  'remediation. Filter, not verdict: automation covers ~1/3 of WCAG; '
152
155
  'query a11y_criterion for what a criterion means.'),
153
156
  'inputSchema': {'type': 'object', 'properties': {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kinti/a11y-toolkit",
3
- "version": "5.28.0",
3
+ "version": "5.29.0",
4
4
  "mcpName": "io.github.kinti/a11y-toolkit",
5
5
  "description": "Zero-dependency WCAG 2.2 accessibility engine (37 MCP tools + CLI): audits, contrast fixing, SHA-256-sealed evidence packs, SARIF, EARL/ACT, CI ratchet. Self-contained: the pure-stdlib Python engine ships inside and runs via python3 \u2014 no downloads, no installs.",
6
6
  "license": "MIT",