Match controls disabled by an ancestor fieldset

FE
1d ago
+168-3

For <fieldset disabled><input></fieldset>, :disabled currently matches only the fieldset and :enabled matches the input. Apply fieldset inheritance outside each ancestor's first direct legend, including when the disabled ancestor is above the query root. Custom pseudo aliases keep their existing context behavior.

Options and optgroups also inherit their select's disabled state, as specified by the current HTML Standard. The installed Chromium differs for this case, so those expectations follow the standard.

Regressions were verified before their respective fixes. All 227 tests pass (one existing skip); ESLint, TypeScript, build, and changed-file Biome pass. Full Biome has existing CRLF formatting failures. Tests cover nested legends, explicit disabled states, scoped queries, and custom aliases. Firefox, WebKit, and benchmarks were not run.

Summary by CodeRabbit

  • Bug Fixes
    • Updated :disabled matching to account for disabled fieldsets and their supported form controls, including nested fieldsets, select options, and optgroups. Controls inside the first direct legend remain exempt from inherited disabled state, while explicitly disabled fieldsets are still matched.
    • Improved :enabled matching for options and ensured disabled-state results remain consistent in scoped queries and element checks.