This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 24901 - Perhaps you should define how elements are supposed to treat (invalid) child nodes, especially in XHTML where content of <textarea> is parsed normally and handled by UAs, even if invalid (IE shows phr [...]
Summary: Perhaps you should define how elements are supposed to treat (invalid) child ...
Status: RESOLVED WONTFIX
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-03 21:15 UTC by contributor
Modified: 2014-03-07 23:05 UTC (History)
9 users (show)

See Also:


Attachments
Provided example rendered on Safari 5.1.7 for Windows 8.1 (49.52 KB, image/png)
2014-03-05 21:35 UTC, Andrea Rendine
Details

Description contributor 2014-03-03 21:15:44 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html
Multipage: http://www.whatwg.org/C#concept-textarea-api-value
Complete: http://www.whatwg.org/c#concept-textarea-api-value
Referrer: http://www.whatwg.org/specs/web-apps/current-work/multipage/

Comment:
Perhaps you should define how elements are supposed to treat (invalid) child
nodes, especially in XHTML where content of <textarea> is parsed normally and
handled by UAs, even if invalid (IE shows phrasing content nodes with the
usual graphical appearance).

Posted from: 84.220.11.90 by master.skywalker.88@gmail.com
User agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36
Comment 1 Ian 'Hixie' Hickson 2014-03-04 23:58:49 UTC
In what sense is it not defined?
Comment 2 Andrea Rendine 2014-03-05 13:56:17 UTC
The element has as a content model "text", and along with <title> is defined as one of the 2 "escapable raw text elements", so having child nodes inside them is invalid.
Thus said, in <title> it is stated that:
[The IDL attribute 'text' must return a concatenation of the contents of all the Text nodes that are children of the title element (ignoring any other nodes such as comments or elements), in tree order. On setting, it must act the same way as the textContent IDL attribute.]
This requirement helps handling invalid cases.

For <textarea> the normative previsions often refer to the element's textContent IDL attribute: 
[When the textarea element's textContent IDL attribute changes value, if the element's dirty value flag is false, then the element's raw value must be set to the value of the element's textContent IDL attribute.]
[The reset algorithm for textarea elements is to set the element's value to the value of the element's textContent IDL attribute.]
[The defaultValue IDL attribute must act like the element's textContent IDL attribute.]

Following the reference to the textContent IDL attribute in the DOM specification, the explanation is:
[The textContent attribute must return the following, depending on the context object:... Element - The concatenation of data of all the Text node descendants of the context object, in tree order.]
"Text node descendants" are the text node children and the text nodes inside descendant elements, I guess.
So in a case when the DOM for this element can be represented like this:

     ...
     |
     +-- HTML textarea element (node 1)
     |    |
     |    +-- #text node: "hello" (node 2)
     |    |
     |    +-- HTML em element (node 3)
     |    |    |
     |    |    +-- #text node: "cruel" (node 4)
     |    |
     |    +-- #text node: "world" (node 5)
    ...

so far the raw value for such an element, according to the hints in the spec, should be "hellocruelworld". In XHTML documents, this behavior is followed only by IE (version 11, for what I know; emulation of previous versions is not reliable IMO). This browser, in fact, shows as value the whole textContent of textarea, i.e. its children text nodes and the text content of children elements (already (invalidly) present or inserted via javascript), even formatting the elements with default defined graphical appearance (bold for b and strong, italic for i and em, and so on). The API value and the submission value return the textContent without elements (of course), as stated before.
The other 4 major browsers do not show children elements' text content and as API value and submission value return only the children text nodes.
I know that it's an edge case, but it would be better if the spec explained the origin of the "initial value", especially if the intended purpose was the same of <title> element (i.e. only children text nodes), also considering that 4 out of 5 browsers behave this way.
Comment 3 Ian 'Hixie' Hickson 2014-03-05 21:08:16 UTC
http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2867

Safari and IE do descendant text nodes.
Chrome and Firefox do children text nodes.

Doesn't seem that compelling to change, given that this only affects invalid content anyway. But maybe someone from Chrome or Firefox has an argument to make for why their way is better?
Comment 4 Andrea Rendine 2014-03-05 21:35:37 UTC
Created attachment 1449 [details]
Provided example rendered on Safari 5.1.7 for Windows 8.1

Safari 5.1.7 for Windows does children too.
I know that it's just stuff related to invalid documents, it's only a matter of completeness (or browser compliance if the correct version is descendants, which seems more logic).
Comment 5 Ian 'Hixie' Hickson 2014-03-06 22:51:28 UTC
Safari 5.x is obsolete (even though it's the latest version on Windows).
Comment 6 Ian 'Hixie' Hickson 2014-03-07 23:05:43 UTC
Given the lack of compelling arguments to move away from the Safari/IE model here, I've left the spec as-is. Please reopen the bug if there's a reason to prefer the Firefox/Chrome model.