feat: add observer for 'selected' setter of HTMLOptionElement and try to fix issue #746 (#810)

* feat: add observer for 'selected' setter of HTMLOptionElement and try to fix issue #746

* style: add description of mechanism
This commit is contained in:
Yun Feng
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 0153270680
commit b277b9a7a6
3 changed files with 10 additions and 4 deletions

View File

@@ -491,7 +491,7 @@ function serializeNode(
}
}
if (tagName === 'option') {
if ((n as HTMLOptionElement).selected) {
if ((n as HTMLOptionElement).selected && !maskInputOptions['select']) {
attributes.selected = true;
} else {
// ignore the html attribute (which corresponds to DOM (n as HTMLOptionElement).defaultSelected)