From 3919dd55c62c639491a596aa355adc86192b7ec2 Mon Sep 17 00:00:00 2001
From: Ryan Nowak
Date: Sat, 27 Jul 2019 11:20:52 -0700
Subject: [PATCH] Fix globalization for `@bind-value`
Fixes: #12631
These mappings were missing and adding them restores the correct
behaviour. Mixing up the usage of `@bind` vs `@bind-value` so we have
more coverage of this.
---
...oft.AspNetCore.Components.Web.netstandard2.0.cs | 2 ++
src/Components/Web/src/BindAttributes.cs | 2 ++
.../BasicTestApp/BindCasesComponent.razor | 14 ++++++++------
.../BasicTestApp/GlobalizationBindCases.razor | 10 ++++++----
4 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/src/Components/Web/ref/Microsoft.AspNetCore.Components.Web.netstandard2.0.cs b/src/Components/Web/ref/Microsoft.AspNetCore.Components.Web.netstandard2.0.cs
index c64178d486..30fc3e3d99 100644
--- a/src/Components/Web/ref/Microsoft.AspNetCore.Components.Web.netstandard2.0.cs
+++ b/src/Components/Web/ref/Microsoft.AspNetCore.Components.Web.netstandard2.0.cs
@@ -6,7 +6,9 @@ namespace Microsoft.AspNetCore.Components
[Microsoft.AspNetCore.Components.BindElementAttribute("select", null, "value", "onchange")]
[Microsoft.AspNetCore.Components.BindElementAttribute("textarea", null, "value", "onchange")]
[Microsoft.AspNetCore.Components.BindInputElementAttribute("checkbox", null, "checked", "onchange", false, null)]
+ [Microsoft.AspNetCore.Components.BindInputElementAttribute("date", "value", "value", "onchange", true, "yyyy-MM-dd")]
[Microsoft.AspNetCore.Components.BindInputElementAttribute("date", null, "value", "onchange", true, "yyyy-MM-dd")]
+ [Microsoft.AspNetCore.Components.BindInputElementAttribute("number", "value", "value", "onchange", true, null)]
[Microsoft.AspNetCore.Components.BindInputElementAttribute("number", null, "value", "onchange", true, null)]
[Microsoft.AspNetCore.Components.BindInputElementAttribute("text", null, "value", "onchange", false, null)]
[Microsoft.AspNetCore.Components.BindInputElementAttribute(null, "value", "value", "onchange", false, null)]
diff --git a/src/Components/Web/src/BindAttributes.cs b/src/Components/Web/src/BindAttributes.cs
index 69b4720b0a..91a1ee894c 100644
--- a/src/Components/Web/src/BindAttributes.cs
+++ b/src/Components/Web/src/BindAttributes.cs
@@ -24,9 +24,11 @@ namespace Microsoft.AspNetCore.Components
// type="number" is invariant culture
[BindInputElement("number", null, "value", "onchange", isInvariantCulture: true, format: null)]
+ [BindInputElement("number", "value", "value", "onchange", isInvariantCulture: true, format: null)]
// type="date" is invariant culture with a specific format
[BindInputElement("date", null, "value", "onchange", isInvariantCulture: true, format: "yyyy-MM-dd")]
+ [BindInputElement("date", "value", "value", "onchange", isInvariantCulture: true, format: "yyyy-MM-dd")]
[BindElement("select", null, "value", "onchange")]
[BindElement("textarea", null, "value", "onchange")]
diff --git a/src/Components/test/testassets/BasicTestApp/BindCasesComponent.razor b/src/Components/test/testassets/BasicTestApp/BindCasesComponent.razor
index 6f132f6f6a..5cdd9087ea 100644
--- a/src/Components/test/testassets/BasicTestApp/BindCasesComponent.razor
+++ b/src/Components/test/testassets/BasicTestApp/BindCasesComponent.razor
@@ -1,5 +1,7 @@
Bind cases
+@* There are a mix of cases here using bind and bind-value for coverage *@
+
Textbox
Initially blank:
@@ -32,7 +34,7 @@
Nullable int:
-
+
@textboxNullableIntValue
@@ -50,7 +52,7 @@
float:
-
+
@textboxFloatValue
@@ -74,7 +76,7 @@
decimal:
-
+
@textboxDecimalValue
@@ -119,7 +121,7 @@
Nullable DateTime:
-
+
@textboxNullableDateTimeValue
@@ -149,7 +151,7 @@
DateTime (format):
-
+
@textboxDateTimeFormatValue
@@ -161,7 +163,7 @@
DateTime (format / invalid value):
-
+
@textboxDateTimeFormatInvalidValue
diff --git a/src/Components/test/testassets/BasicTestApp/GlobalizationBindCases.razor b/src/Components/test/testassets/BasicTestApp/GlobalizationBindCases.razor
index bc7a53c4a3..9f4dadf7a9 100644
--- a/src/Components/test/testassets/BasicTestApp/GlobalizationBindCases.razor
+++ b/src/Components/test/testassets/BasicTestApp/GlobalizationBindCases.razor
@@ -3,6 +3,8 @@
Globalization Bind Cases
Culture is: @System.Globalization.CultureInfo.CurrentCulture.Name
+@* There are a mix of cases here using bind and bind-value for coverage *@
+
@@ -22,7 +24,7 @@
@inputTypeTextDateTime
- DateTimeOffset:
+ DateTimeOffset:
@inputTypeTextDateTimeOffset
@@ -34,7 +36,7 @@
@inputTypeNumberInt
- decimal:
+ decimal:
@inputTypeNumberDecimal
@@ -47,7 +49,7 @@
@inputTypeDateDateTime
- DateTimeOffset:
+ DateTimeOffset:
@inputTypeDateDateTimeOffset