Skip to content

Commit 709933e

Browse files
committed
fix internal value processing and more tests
1 parent 8cf9c66 commit 709933e

3 files changed

Lines changed: 337 additions & 9 deletions

File tree

src/main/java/org/htmlunit/html/HtmlTextArea.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,16 @@ public final void setText(final String newValue) {
171171
}
172172

173173
private void setTextInternal(final String newValue) {
174+
final String oldValue = getText();
175+
174176
rawValue_ = newValue;
175177
isValueDirty_ = true;
176178

177-
final int pos = newValue.length();
178-
setSelectionStart(pos);
179-
setSelectionEnd(pos);
179+
if (!newValue.equals(oldValue)) {
180+
final int pos = newValue.length();
181+
setSelectionStart(pos);
182+
setSelectionEnd(pos);
183+
}
180184
}
181185

182186
/**

src/test/java/org/htmlunit/html/HtmlTextAreaTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ public void typingAndClone() throws Exception {
330330
HtmlTextArea input = (HtmlTextArea) page.getElementById("foo");
331331
input = (HtmlTextArea) input.cloneNode(true);
332332
input.type("4711");
333-
assertEquals("4711", input.getTextContent());
333+
assertEquals("4711", input.getText());
334+
assertEquals("", input.getTextContent());
334335
}
335336

336337
/**
@@ -355,7 +356,8 @@ public void typingAndReset() throws Exception {
355356
input.reset();
356357
input.type("0815");
357358

358-
assertEquals("0815", input.getTextContent());
359+
assertEquals("0815", input.getText());
360+
assertEquals("", input.getTextContent());
359361
}
360362

361363
/**
@@ -380,6 +382,7 @@ public void typingAndSetTextContent() throws Exception {
380382
input.setTextContent("");
381383
input.type("0815");
382384

383-
assertEquals("0815", input.getTextContent());
385+
assertEquals("47110815", input.getText());
386+
assertEquals("", input.getTextContent());
384387
}
385388
}

0 commit comments

Comments
 (0)