File tree Expand file tree Collapse file tree
main/java/org/htmlunit/html Expand file tree Collapse file tree Original file line number Diff line number Diff 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 /**
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments