Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Issue 1221233003: HTMLTextAreaElement.defaultValue is not implemented as per spec

Created:
5 years, 5 months ago by Sunil Ratnu
Modified:
5 years, 5 months ago
Reviewers:
tkent
CC:
blink-reviews, arv+blink, vivekg_samsung, blink-reviews-html_chromium.org, vivekg, dglazkov+blink, Inactive
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Target Ref:
refs/heads/master
Project:
blink
Visibility:
Public.

Description

HTMLTextAreaElement.defaultValue is not implemented as per spec According to the HTML5 specification, HTMLTextAreaElement.defaultValue should be the same as textContent. The special feature in Blink is to preserve comment nodes in the textarea. Since it's quite hard to get them into the textarea (contents are CDATA) it seems like a strange feature. This patch syncs it with the spec. Spec: http://dev.w3.org/html5/spec-preview/the-textarea-element.html#dom-textarea-defaultvalue BUG=392843

Patch Set 1 : #

Patch Set 2 : Fix test failures #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+33 lines, -29 lines) Patch
A LayoutTests/fast/dom/HTMLTextAreaElement/get-default-value.html View 1 chunk +19 lines, -0 lines 0 comments Download
A LayoutTests/fast/dom/HTMLTextAreaElement/get-default-value-expected.txt View 1 chunk +11 lines, -0 lines 0 comments Download
M Source/core/html/HTMLTextAreaElement.cpp View 1 1 chunk +3 lines, -29 lines 2 comments Download

Messages

Total messages: 9 (2 generated)
Sunil Ratnu
Please review this. https://codereview.chromium.org/1221233003/diff/40001/Source/core/html/HTMLTextAreaElement.cpp File Source/core/html/HTMLTextAreaElement.cpp (right): https://codereview.chromium.org/1221233003/diff/40001/Source/core/html/HTMLTextAreaElement.cpp#newcode422 Source/core/html/HTMLTextAreaElement.cpp:422: if (!m_isDirty) I tried using ImplementedAs=textContent ...
5 years, 5 months ago (2015-07-10 07:47:26 UTC) #3
tkent
https://codereview.chromium.org/1221233003/diff/40001/Source/core/html/HTMLTextAreaElement.cpp File Source/core/html/HTMLTextAreaElement.cpp (right): https://codereview.chromium.org/1221233003/diff/40001/Source/core/html/HTMLTextAreaElement.cpp#newcode422 Source/core/html/HTMLTextAreaElement.cpp:422: if (!m_isDirty) On 2015/07/10 07:47:26, Sunil Ratnu wrote: > ...
5 years, 5 months ago (2015-07-10 07:59:40 UTC) #4
Sunil Ratnu
> https://codereview.chromium.org/1221233003/diff/40001/Source/core/html/HTMLTextAreaElement.cpp > File Source/core/html/HTMLTextAreaElement.cpp (right): > > https://codereview.chromium.org/1221233003/diff/40001/Source/core/html/HTMLTextAreaElement.cpp#newcode422 > Source/core/html/HTMLTextAreaElement.cpp:422: if (!m_isDirty) > On ...
5 years, 5 months ago (2015-07-10 13:19:32 UTC) #5
tkent
On 2015/07/10 13:19:32, Sunil Ratnu wrote: > > > https://codereview.chromium.org/1221233003/diff/40001/Source/core/html/HTMLTextAreaElement.cpp > > File Source/core/html/HTMLTextAreaElement.cpp (right): ...
5 years, 5 months ago (2015-07-14 01:15:13 UTC) #6
Sunil Ratnu
On 2015/07/14 01:15:13, tkent wrote: > On 2015/07/10 13:19:32, Sunil Ratnu wrote: > > > ...
5 years, 5 months ago (2015-07-14 06:21:41 UTC) #7
tkent
On 2015/07/14 06:21:41, Sunil Ratnu wrote: > This is the testcase which I tested: > ...
5 years, 5 months ago (2015-07-14 07:43:19 UTC) #8
Sunil Ratnu
5 years, 5 months ago (2015-07-20 12:28:58 UTC) #9
On 2015/07/14 07:43:19, tkent wrote:
> On 2015/07/14 06:21:41, Sunil Ratnu wrote:
> > This is the testcase which I tested:
> > 
> >     var ta = document.getElementById('ta');
> >     ta.defaultValue = 'abc123456';
> >     alert(ta.selectionStart + "," + ta.selectionEnd);
> > 
> >     ta.setSelectionRange(2, 3);
> >     ta.defaultValue = 'abc123456';
> >     alert(ta.selectionStart + "," + ta.selectionEnd);
> > 
> >     ta.textContent = "abc123456";
> >     alert(ta.selectionStart + "," + ta.selectionEnd);
> > 
> >     ta.setSelectionRange(2, 3);
> >     ta.textContent = 'abc123456';
> >     alert(ta.selectionStart + "," + ta.selectionEnd);
> > 
> > Following are the values for different browsers:
> > 
> >           alert1   alert2   alert3   alert4
> >     IE:     0,0      2,3      0,0      0,0
> >     FF:     0,0      9,9      9,9      9,9
> >     Chrome: 9,9      9,9      9,9      2,3
> > 
> > So, IE keeps the selection start and end at the start of the text i.e. 0,0
> until
> > and unless we specifically set the selection to some values.
> >     FF, for the first time sets the value to the start of the text (i.e.
0,0).
> > After that it is always at the end of the text.
> >     Chrome, for the very first time, sets the values at the end of the text
> > (i.e. 9,9) but in case of setting same textContent it does not set the
values
> to
> >    
> >     9,9, instead it retains the earlier selection of 2,3.
> 
> Thank you for the investigation.
> According to the specification, updating the default value doesn't move
> selection.  So, IMO, 
> 0,0 2,3 0,0 2,3
> is what we want.
> 

Thanks for the response tkent. I will try to have a fix so that we can achieve
the desired behaviour.

> However the specification doesn't mention the behavior in a case that updated
> default value is shorter than selectionStart/selectionEnd.  We need to file a
> specification bug.

I will file a specification bug for this as well.

Powered by Google App Engine
This is Rietveld 408576698