iter(g341): 表单错误文案补 aria-describedby 关联
This commit is contained in:
@@ -1670,6 +1670,21 @@ function checkToastLive(pkgs) {
|
||||
return issues;
|
||||
}
|
||||
|
||||
/*** 校验表单错误关联:只标 aria-invalid 时读屏只说「无效」,原因(哪条规则没过)听不到 ***/
|
||||
function checkFormErrorLink(pkgs) {
|
||||
const issues = [];
|
||||
for (const pkg of pkgs) {
|
||||
if (pkg.type !== 'skin-dom') continue;
|
||||
const formPath = path.join(ROOT, pkg.dir, 'src', 'form.ts');
|
||||
if (!fs.existsSync(formPath)) continue;
|
||||
const src = fs.readFileSync(formPath, 'utf8');
|
||||
if (!/id: `\$\{fid\}-error`/.test(src)) issues.push(`${pkg.name}/src/form.ts 的错误区缺派生 id:没有 id 就无法被 aria-describedby 指过来`);
|
||||
if (!/setAttribute\('aria-describedby', described\)/.test(src)) issues.push(`${pkg.name}/src/form.ts 缺 aria-describedby 落笔:校验失败时读屏只会念「无效」,念不出「至少 6 个字符」这类原因`);
|
||||
if (!/removeAttribute\('aria-describedby'\)/.test(src)) issues.push(`${pkg.name}/src/form.ts 缺 aria-describedby 清除:校验通过后关联还指着错误区,读屏会把空节点当说明`);
|
||||
}
|
||||
return issues;
|
||||
}
|
||||
|
||||
/*** 校验同义词表:目标 id 必须真实存在(改名后残留会让回退指到空气),同一个词不得归两组(歧义会让结果随表序漂移) ***/
|
||||
function checkSynonyms(ids) {
|
||||
const issues = [];
|
||||
@@ -1752,6 +1767,7 @@ function cmdVerify() {
|
||||
issues.push(...checkReadme(pkgs));
|
||||
issues.push(...checkAriaNames(pkgs)); // 输入控件必须有可访问名
|
||||
issues.push(...checkToastLive(pkgs)); // toast 必须有 live 区域与 alert 抢占
|
||||
issues.push(...checkFormErrorLink(pkgs)); // 表单错误文案必须被控件关联
|
||||
issues.push(...checkSynonyms(new Set(pkgs.flatMap((p) => (p.docs?.components ?? []).map((c) => c.id))))); // 同义词表指向的组件必须真实存在
|
||||
checkDarkTokens(issues);
|
||||
checkTokenParity(issues);
|
||||
|
||||
Reference in New Issue
Block a user