W3C home > Mailing lists > Public > public-html-bugzilla@w3.org > April 2011

[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

From: <bugzilla@jessica.w3.org>
Date: Fri, 08 Apr 2011 19:19:16 +0000
To: public-html-bugzilla@w3.org
Message-Id: <E1Q8HDA-0003c0-3W@jessica.w3.org>
http://www.w3.org/Bugs/Public/show_bug.cgi?id=12449

Aryeh Gregor <Simetrical+w3cbug@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Simetrical+w3cbug@gmail.com

--- Comment #1 from Aryeh Gregor <Simetrical+w3cbug@gmail.com> 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.

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
Received on Friday, 8 April 2011 19:19:17 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 16:31:08 UTC