no-duplicate-autofocus
同一のautofocusスコープ起点要素を共有する複数の要素にautofocus属性を指定することを禁止します。HTML Living Standardにより、同じ直近の祖先autofocusスコープ起点要素を共有する2つ以上の要素にautofocus属性を指定してはなりません。
要素のスコープ起点は、その要素自身がdialog要素であるかpopover属性を持つ場合はその要素自身、それ以外の場合は直近のそのような祖先要素、いずれも無ければ文書全体です。したがって2つのdialog要素やpopover要素は、それぞれ独立してautofocus対象を持つことができます。
❌ 間違ったコード例
<input autofocus /> <button autofocus>送信</button>
<dialog>
<input autofocus />
<button autofocus>送信</button>
</dialog>
✅ 正しいコード例
<input autofocus /> <button>送信</button>
<dialog><input autofocus /></dialog>
<dialog><button autofocus>送信</button></dialog>
Interface
{
"no-duplicate-autofocus": boolean
}
ドキュメント内で複数の要素にautofocus属性を指定することを禁止します。
Default Severity
error