iter(g342): 重置按钮逐项复位字段与错误态
This commit is contained in:
@@ -1685,6 +1685,21 @@ function checkFormErrorLink(pkgs) {
|
||||
return issues;
|
||||
}
|
||||
|
||||
/*** 校验表单重置:只跑 onReset 回调等于「点了没反应」,按钮名叫重置就得真复位 ***/
|
||||
function checkFormReset(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 (!/return \{ el, validate, validateAsync, reset \}/.test(src)) issues.push(`${pkg.name}/src/form.ts 的字段句柄没暴露 reset:form 拿不到复位入口`);
|
||||
if (!/for \(const item of items\) item\.reset\(\);/.test(src)) issues.push(`${pkg.name}/src/form.ts 的重置没逐项复位:只调 onReset 时点「重置」等于什么都不干,红框还留在屏幕上`);
|
||||
if (!/type: 'button', onClick: doReset/.test(src)) issues.push(`${pkg.name}/src/form.ts 的重置按钮没接到 doReset:会退回只跑回调的空壳`);
|
||||
}
|
||||
return issues;
|
||||
}
|
||||
|
||||
/*** 校验同义词表:目标 id 必须真实存在(改名后残留会让回退指到空气),同一个词不得归两组(歧义会让结果随表序漂移) ***/
|
||||
function checkSynonyms(ids) {
|
||||
const issues = [];
|
||||
@@ -1768,6 +1783,7 @@ function cmdVerify() {
|
||||
issues.push(...checkAriaNames(pkgs)); // 输入控件必须有可访问名
|
||||
issues.push(...checkToastLive(pkgs)); // toast 必须有 live 区域与 alert 抢占
|
||||
issues.push(...checkFormErrorLink(pkgs)); // 表单错误文案必须被控件关联
|
||||
issues.push(...checkFormReset(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