Skip to content

Commit 6e3c86d

Browse files
committed
fix: add textarea support
Fixes #8
1 parent fa736bb commit 6e3c86d

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

lib/bind.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ var Bind = (function Bind(global) {
167167
// matched from the selector (set up below), that checks
168168
// the node type, and either sets the input.value or
169169
// element.innerHTML to the value
170-
var valueSetters = ['SELECT', 'INPUT', 'PROGRESS'];
170+
var valueSetters = ['SELECT', 'INPUT', 'PROGRESS', 'TEXTAREA'];
171171

172172
if (value === null || value === undefined) {
173173
if (valueSetters.indexOf(elements[0].nodeName) !== -1) {
@@ -238,7 +238,7 @@ var Bind = (function Bind(global) {
238238
// let's make the binding two way...
239239
// note that this doesn't support event delegation
240240
forEach(elements, function (element) {
241-
if (element.nodeName === 'INPUT' || element.nodeName === 'SELECT') {
241+
if (element.nodeName === 'INPUT' || element.nodeName === 'SELECT' || element.nodeName === 'TEXTAREA') {
242242
var oninput = function () {
243243
// we set a dirty flag against this dom node to prevent a
244244
// circular update / max stack explode

test/two-way.browser.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ describe('two way data bind', function () {
4646
assert.ok(found === 3, 'found ' + found);
4747
});
4848

49+
it('should update textarea elements', function () {
50+
var ta = document.querySelector('textarea');
51+
assert.equal(ta.value, data.body, 'textarea was updated');
52+
});
53+
4954
it('should update data based on element changes', function (done) {
5055
var node = document.querySelector('input.score');
5156
node.value = 10;

test/two-way.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
<progress class="score" min=0 max=100 value=0>
44

55
<span class="name">Remy</span>
6-
<input class="name">
6+
<input class="name">
7+
8+
<textarea class="body"></textarea>

0 commit comments

Comments
 (0)