Support short values in <input type='number'/>
This commit is contained in:
parent
346eceaadb
commit
8a0be19abe
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Components.Forms
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An input component for editing numeric values.
|
/// An input component for editing numeric values.
|
||||||
/// Supported numeric types are <see cref="int"/>, <see cref="long"/>, <see cref="float"/>, <see cref="double"/>, <see cref="decimal"/>.
|
/// Supported numeric types are <see cref="int"/>, <see cref="long"/>, <see cref="short"/>, <see cref="float"/>, <see cref="double"/>, <see cref="decimal"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class InputNumber<TValue> : InputBase<TValue>
|
public class InputNumber<TValue> : InputBase<TValue>
|
||||||
{
|
{
|
||||||
|
|
@ -22,6 +22,7 @@ namespace Microsoft.AspNetCore.Components.Forms
|
||||||
var targetType = Nullable.GetUnderlyingType(typeof(TValue)) ?? typeof(TValue);
|
var targetType = Nullable.GetUnderlyingType(typeof(TValue)) ?? typeof(TValue);
|
||||||
if (targetType == typeof(int) ||
|
if (targetType == typeof(int) ||
|
||||||
targetType == typeof(long) ||
|
targetType == typeof(long) ||
|
||||||
|
targetType == typeof(short) ||
|
||||||
targetType == typeof(float) ||
|
targetType == typeof(float) ||
|
||||||
targetType == typeof(double) ||
|
targetType == typeof(double) ||
|
||||||
targetType == typeof(decimal))
|
targetType == typeof(decimal))
|
||||||
|
|
@ -86,6 +87,9 @@ namespace Microsoft.AspNetCore.Components.Forms
|
||||||
case long @long:
|
case long @long:
|
||||||
return BindConverter.FormatValue(@long, CultureInfo.InvariantCulture);
|
return BindConverter.FormatValue(@long, CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
|
case short @short:
|
||||||
|
return BindConverter.FormatValue(@short, CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
case float @float:
|
case float @float:
|
||||||
return BindConverter.FormatValue(@float, CultureInfo.InvariantCulture);
|
return BindConverter.FormatValue(@float, CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue