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.
This commit is contained in:
Ryan Nowak 2019-07-27 11:20:52 -07:00 committed by Ryan Nowak
parent 82478eac6b
commit 3919dd55c6
4 changed files with 18 additions and 10 deletions

View File

@ -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)]

View File

@ -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")]

View File

@ -1,5 +1,7 @@
<h3 id="bind-cases">Bind cases</h3>
@* There are a mix of cases here using bind and bind-value for coverage *@
<h2>Textbox</h2>
<p>
Initially blank:
@ -32,7 +34,7 @@
</p>
<p>
Nullable int:
<input id="textbox-nullable-int" @bind="textboxNullableIntValue" type="number" />
<input id="textbox-nullable-int" @bind-value="textboxNullableIntValue" type="number" />
<span id="textbox-nullable-int-value">@textboxNullableIntValue</span>
<input id="textbox-nullable-int-mirror" @bind="textboxNullableIntValue" readonly />
</p>
@ -50,7 +52,7 @@
</p>
<p>
float:
<input id="textbox-float" @bind="textboxFloatValue" type="number" />
<input id="textbox-float" @bind-value="textboxFloatValue" type="number" />
<span id="textbox-float-value">@textboxFloatValue</span>
<input id="textbox-float-mirror" @bind="textboxFloatValue" readonly />
</p>
@ -74,7 +76,7 @@
</p>
<p>
decimal:
<input id="textbox-decimal" @bind="textboxDecimalValue" type="number" />
<input id="textbox-decimal" @bind-value="textboxDecimalValue" type="number" />
<span id="textbox-decimal-value">@textboxDecimalValue</span>
<input id="textbox-decimal-mirror" @bind="textboxDecimalValue" readonly />
</p>
@ -119,7 +121,7 @@
</p>
<p>
Nullable DateTime:
<input id="textbox-nullable-datetime" @bind="textboxNullableDateTimeValue" type="text" />
<input id="textbox-nullable-datetime" @bind-value="textboxNullableDateTimeValue" type="text" />
<span id="textbox-nullable-datetime-value">@textboxNullableDateTimeValue</span>
<input id="textbox-nullable-datetime-mirror" @bind="textboxNullableDateTimeValue" readonly />
</p>
@ -149,7 +151,7 @@
</p>
<p>
DateTime (format):
<input id="textbox-datetime-format" @bind="textboxDateTimeFormatValue" type="text" @bind:format="MM-dd" />
<input id="textbox-datetime-format" @bind-value="textboxDateTimeFormatValue" type="text" @bind-value:format="MM-dd" />
<span id="textbox-datetime-format-value">@textboxDateTimeFormatValue</span>
<input id="textbox-datetime-format-mirror" @bind="textboxDateTimeFormatValue" readonly />
</p>
@ -161,7 +163,7 @@
</p>
<p>
DateTime (format / invalid value):
<input id="textbox-datetime-format-invalid" @bind="textboxDateTimeFormatInvalidValue" type="text" @bind:format="MM-dd" />
<input id="textbox-datetime-format-invalid" @bind-value="textboxDateTimeFormatInvalidValue" type="text" @bind-value:format="MM-dd" />
<span id="textbox-datetime-format-invalid-value">@textboxDateTimeFormatInvalidValue</span>
<input id="textbox-datetime-format-invalid-mirror" @bind="textboxDateTimeFormatInvalidValue" readonly />
</p>

View File

@ -3,6 +3,8 @@
<h3 id="globalization-cases">Globalization Bind Cases</h3>
<h3 id="culture-name-display">Culture is: @System.Globalization.CultureInfo.CurrentCulture.Name</h3>
@* There are a mix of cases here using bind and bind-value for coverage *@
<div>
<p>Numbers using bind in text fields</p>
<div>
@ -10,7 +12,7 @@
<span id="input_type_text_int_value">@inputTypeTextInt</span>
</div>
<div>
decimal: <input type="text" id="input_type_text_decimal" @bind="inputTypeTextDecimal" />
decimal: <input type="text" id="input_type_text_decimal" @bind-value="inputTypeTextDecimal" />
<span id="input_type_text_decimal_value">@inputTypeTextDecimal</span>
</div>
</div>
@ -22,7 +24,7 @@
<span id="input_type_text_datetime_value">@inputTypeTextDateTime</span>
</div>
<div>
DateTimeOffset: <input type="text" id="input_type_text_datetimeoffset" @bind="inputTypeTextDateTimeOffset" />
DateTimeOffset: <input type="text" id="input_type_text_datetimeoffset" @bind-value="inputTypeTextDateTimeOffset" />
<span id="input_type_text_datetimeoffset_value">@inputTypeTextDateTimeOffset</span>
</div>
</div>
@ -34,7 +36,7 @@
<span id="input_type_number_int_value">@inputTypeNumberInt</span>
</div>
<div>
decimal: <input type="number" id="input_type_number_decimal" @bind="inputTypeNumberDecimal" />
decimal: <input type="number" id="input_type_number_decimal" @bind-value="inputTypeNumberDecimal" />
<span id="input_type_number_decimal_value">@inputTypeNumberDecimal</span>
</div>
</div>
@ -47,7 +49,7 @@
<span id="input_type_date_datetime_value">@inputTypeDateDateTime</span>
</div>
<div>
DateTimeOffset: <input type="text" id="input_type_date_datetimeoffset_extrainput" @bind="inputTypeDateDateTimeOffset" />
DateTimeOffset: <input type="text" id="input_type_date_datetimeoffset_extrainput" @bind-value="inputTypeDateDateTimeOffset" />
<input type="date" id="input_type_date_datetimeoffset" @bind="inputTypeDateDateTimeOffset" />
<span id="input_type_date_datetimeoffset_value">@inputTypeDateDateTimeOffset</span>
</div>