Text Area Bind Fix for issue #434 (#439)

* Text Area Bind Fix for issue #434

* Correct Typo/Mispelling on test method name.
This commit is contained in:
Ryouko Konpaku 2018-03-30 17:10:23 +08:00 committed by Steve Sanderson
parent cda3692d0b
commit ef3db51bbf
3 changed files with 45 additions and 0 deletions

View File

@ -228,6 +228,7 @@ export class BrowserRenderer {
switch (element.tagName) {
case 'INPUT':
case 'SELECT':
case 'TEXTAREA':
if (isCheckbox(element)) {
(element as HTMLInputElement).checked = value === 'True';
} else {

View File

@ -47,6 +47,35 @@ namespace Microsoft.AspNetCore.Blazor.E2ETest.Tests
target.SendKeys("Changed value\t");
Assert.Equal("Changed value", boundValue.Text);
}
[Fact]
public void CanBindTextArea_InitiallyBlank()
{
var target = Browser.FindElement(By.Id("textarea-initially-blank"));
var boundValue = Browser.FindElement(By.Id("textarea-initially-blank-value"));
Assert.Equal(string.Empty, target.GetAttribute("value"));
Assert.Equal(string.Empty, boundValue.Text);
// Modify target; verify value is updated
target.SendKeys("Changed value");
Assert.Equal(string.Empty, boundValue.Text); // Don't update as there's no change event fired yet.
target.SendKeys("\t");
Assert.Equal("Changed value", boundValue.Text);
}
[Fact]
public void CanBindTextArea_InitiallyPopulated()
{
var target = Browser.FindElement(By.Id("textarea-initially-populated"));
var boundValue = Browser.FindElement(By.Id("textarea-initially-populated-value"));
Assert.Equal("Hello", target.GetAttribute("value"));
Assert.Equal("Hello", boundValue.Text);
// Modify target; verify value is updated
target.Clear();
target.SendKeys("Changed value\t");
Assert.Equal("Changed value", boundValue.Text);
}
[Fact]
public void CanBindCheckbox_InitiallyUnchecked()

View File

@ -10,6 +10,18 @@
<span id="textbox-initially-populated-value">@textboxInitiallyPopulatedValue</span>
</p>
<h2>Text Area</h2>
<p>
Initially blank:
<textarea id="textarea-initially-blank" @bind(textAreaIntiallyBlankValue)></textarea>
<span id="textarea-initially-blank-value">@textAreaIntiallyBlankValue</span>
</p>
<p>
Initially populated:
<textarea id="textarea-initially-populated" @bind(textAreaIntiallyPopulatedValue)></textarea>
<span id="textarea-initially-populated-value">@textAreaIntiallyPopulatedValue</span>
</p>
<h2>Checkbox</h2>
<p>
Initially unchecked:
@ -41,6 +53,9 @@
string textboxInitiallyBlankValue = null;
string textboxInitiallyPopulatedValue = "Hello";
string textAreaIntiallyBlankValue = null;
string textAreaIntiallyPopulatedValue = "Hello";
bool checkboxInitiallyUncheckedValue = false;
bool checkboxInitiallyCheckedValue = true;