mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
When a `<select>` element is bound via `[formField]` to a field with a `number | null` model, the native DOM always reads `element.value` as a string. This caused the model to silently receive a string (e.g. `"42"`) instead of the expected number, and writing `null` to `element.value` coerced it to the string `"null"` rather than clearing the selection. Extend `getNativeControlValue` with a `select-one` case that mirrors the existing `<input type="text">` numeric-model logic: when the current model type is `number | null`, parse the selected option's string value as a number, return `null` for an empty selection, and produce a parse error if the option value is not a valid number. Extend `setNativeControlValue` with a matching `select-one` case that converts `null` and `NaN` to `''` (clearing the selection) and writes numeric values as `String(value)`. Replace the bare `input.value = ... as string` assignment in the `observeSelectMutations` callback in `nativeControlCreate` with a call to `setNativeControlValue` so that option-change re-sync also benefits from the same null/number handling. Fixes #68217 |
||
|---|---|---|
| .. | ||
| animations | ||
| benchpress | ||
| common | ||
| compiler | ||
| compiler-cli | ||
| core | ||
| docs/di | ||
| elements | ||
| examples | ||
| forms | ||
| language-service | ||
| localize | ||
| misc/angular-in-memory-web-api | ||
| platform-browser | ||
| platform-browser-dynamic | ||
| platform-server | ||
| private/testing | ||
| router | ||
| service-worker | ||
| ssr/docs | ||
| upgrade | ||
| zone.js | ||
| BUILD.bazel | ||
| circular-deps-test.conf.cjs | ||
| empty.ts | ||
| goog.d.ts | ||
| license-banner.txt | ||
| package.json | ||
| README.md | ||
| system.d.ts | ||
| tsconfig-build.json | ||
| tsconfig-legacy-saucelabs.json | ||
| tsconfig-test.json | ||
| tsconfig.json | ||
| tsec-exemption.json | ||
| types.d.ts | ||
Angular
The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.
Usage information and reference details can be found in Angular documentation.
License: MIT