Commit 15a2552
fix(x-select): make .value reflect the current selection (#263)
x-select's `.value` returned the value ATTRIBUTE, which a user selection never updates
(only the inner <select> + the dispatched select-change event changed). So consumers that
read `el.value` — x-form's collect-values, the demo's status filter — saw a stale value:
the filter looked dead, and forms silently submitted the pre-selection value.
Every other BareDOM form control makes `.value`/`.checked` reflect the current value (the
contract x-form relies on); x-select was the lone exception. Override its `value` getter to
read the live inner <select>, with one disambiguation: a non-empty value set BEFORE its
<option> exists (async-loaded options) is surfaced as pending via the attribute until the
option arrives. This preserves both existing tests (value-attr-not-auto-set-on-change,
string-property-value) and adds two regression tests (selection reflection; set-before-options).
clj-kondo clean; full karma 5190.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent ac00789 commit 15a2552
2 files changed
Lines changed: 84 additions & 1 deletion
File tree
- src/baredom/components/x_select
- test/baredom/components/x_select
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
401 | 442 | | |
402 | | - | |
| 443 | + | |
| 444 | + | |
403 | 445 | | |
404 | 446 | | |
405 | 447 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
327 | 368 | | |
328 | 369 | | |
329 | 370 | | |
| |||
0 commit comments