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 12449 - The definition of the IDL attribute text is misleading, since the syntax allows only text inside a title element. The attribute should be defined as a synonym for innerText (for this element). Existing browsers treat markup inside title element as charact
Summary: The definition of the IDL attribute text is misleading, since the syntax allo...
Status: RESOLVED NEEDSINFO
Alias: None
Product: HTML WG
Classification: Unclassified
Component: LC1 HTML5 spec (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-08 07:47 UTC by contributor
Modified: 2011-08-04 05:17 UTC (History)
4 users (show)

See Also:


Attachments

Description contributor 2011-04-08 07:47:46 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html
Section: http://www.whatwg.org/specs/web-apps/current-work/#the-title-element-0

Comment:
The definition of the IDL attribute text is misleading, since the syntax
allows only text inside a title element. The attribute should be defined as a
synonym for innerText (for this element). Existing browsers treat markup
inside title element as character data, displaying it literally in contexts
where the title element content is used, and this is also reflected in their
implementations of the text and innerText IDL attributes for this element.
Thus, the current wording requires error processing different from the current
one and may break existing software, for no acceptable reason. Authors who
wish to process title elements that may be syntactically invalid should be
encouraged to use the innerHTML property rather than the text property.

Posted from: 88.114.29.18
User agent: Mozilla/5.0 (Windows NT 6.0; rv:2.0) Gecko/20100101 Firefox/4.0
Comment 1 Aryeh Gregor 2011-04-08 19:19:15 UTC
(In reply to comment #0)
> The definition of the IDL attribute text is misleading, since the syntax
> allows only text inside a title element.

It's still possible for a title element to have non-text children, such as in an XML document or if its contents were modified by JavaScript.

> The attribute should be defined as a
> synonym for innerText (for this element).

innerText is not currently defined by any specification.  It's defined to be the same as textContent when setting, and that works the same as innerText for setting.  text does not work the same as textContent or innerText for getting, e.g.

data:text/html,<!doctype html>
<title></title>
<script>
var title = document.querySelector("title");
title.appendChild(document.createElement("b"));
title.firstChild.textContent = "foo";
alert('text is "' + title.text + '", textContent is "' + title.textContent + '"');
</script>

IE9, Firefox 4.0, and Chrome 12 dev all alert 'text is "", textContent is "foo"'.  Your proposed behavior would result in 'text is "foo", textContent is "foo"'.  Opera 11 does this, but presumably it's a bug.

(I tested innerText too, and it works like textContent here in this case for all browsers, not like text -- except for Firefox, which doesn't implement innerText.)

> Existing browsers treat markup
> inside title element as character data, displaying it literally in contexts
> where the title element content is used

That's correct, but this is a property of HTML parsing.  By the time you have a Node object with a text property, parsing is no longer relevant.  The parsing behavior for <title> in text/html is defined here (look for 'A start tag whose tag name is "title"'):

http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#parsing-main-inhead

> and this is also reflected in their
> implementations of the text and innerText IDL attributes for this element.

Not true, as noted above.  text behaves as the spec describes in the simple test case I gave, which is different from textContent and innerText.

> Thus, the current wording requires error processing different from the current
> one and may break existing software, for no acceptable reason. Authors who
> wish to process title elements that may be syntactically invalid should be
> encouraged to use the innerHTML property rather than the text property.

The behavior that the spec describes appears to match browsers.  If you think there are specific ways in which it doesn't, please give specific test-cases where browsers' behavior contradicts the specification.  It is clear that browsers don't implement this the same as innerText or textContent.
Comment 2 Aryeh Gregor 2011-06-24 18:31:57 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are
satisfied with this response, please change the state of this bug to CLOSED. If
you have additional information and would like the Editor to reconsider, please
reopen this bug. If you would like to escalate the issue to the full HTML
Working Group, please add the TrackerRequest keyword to this bug, and suggest
title and text for the Tracker Issue; or you may create a Tracker Issue
yourself, if you are able to do so. For more details, see this document:

   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Additional Information Needed
Change Description: no spec change
Rationale: See comment #1.  Please clarify exactly what parts of the current spec are inaccurate or should be changed -- I couldn't find them based on your description.
Comment 3 Michael[tm] Smith 2011-08-04 05:17:34 UTC
mass-move component to LC1