Skip to content

Commit 37e9862

Browse files
authored
Merge pull request #60 from GreenGremlin/bugfix/textarea-not-updating
Fixing textarea value changes not showing
2 parents bcca7e5 + 1fc6e53 commit 37e9862

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

diffDOM.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,9 @@
707707
objNode.attributes[attribute.name] = attribute.value;
708708
}
709709
}
710-
if (aNode.childNodes && aNode.childNodes.length > 0) {
710+
if (objNode.nodeName === 'TEXTAREA') {
711+
objNode.value = aNode.value;
712+
} else if (aNode.childNodes && aNode.childNodes.length > 0) {
711713
objNode.childNodes = [];
712714
nodeArray = Array.prototype.slice.call(aNode.childNodes);
713715
length = nodeArray.length;
@@ -1110,10 +1112,6 @@
11101112
break;
11111113
case this._const.modifyTextElement:
11121114
node.data = diff[this._const.newValue];
1113-
1114-
if (parentNode.nodeName === 'TEXTAREA') {
1115-
parentNode.value = diff[this._const.newValue];
1116-
}
11171115
break;
11181116
case this._const.modifyValue:
11191117
node.value = diff[this._const.newValue];

tests/form.html

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,29 @@ <h1>Form element test for diffDOM</h1>
192192

193193
theDiff = dd.diff(first, second);
194194

195-
if (theDiff.length === 2) {
195+
if (theDiff.length === 1) {
196+
success(theDiff);
197+
} else {
198+
testFailure();
199+
console.log(theDiff);
200+
}
201+
202+
reportDiv();
203+
204+
second.innerText = 'Some text';
205+
third.innerText = 'Some other text';
206+
207+
reportDivDescription(first, second);
208+
209+
theDiff = dd.diff(first, second);
210+
211+
dd.apply(first, theDiff);
212+
213+
theDiff = dd.diff(first, third);
214+
215+
dd.apply(first, theDiff);
216+
217+
if (first.value === third.value) {
196218
success(theDiff);
197219
} else {
198220
testFailure();

0 commit comments

Comments
 (0)