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 26248 - Spec mismatch between createHTMLDocument and textContent
Summary: Spec mismatch between createHTMLDocument and textContent
Status: RESOLVED WONTFIX
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: DOM (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Anne
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-01 15:01 UTC by Kangil Han
Modified: 2014-07-02 09:19 UTC (History)
5 users (show)

See Also:


Attachments

Description Kangil Han 2014-07-01 15:01:23 UTC
DOMImplementation.createHTMLDocument(title)[1] describes like,
  'Create a Text node, set its data to title (which could be the empty string), and append it to the title element created in the previous step.'
While textContent attribute[2] says,
  'If new value is not the empty string, set node to a new Text node whose data is new value.'

So it is confusing how to handle empty title DOMString on implementation.

[1] http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
[2] http://dom.spec.whatwg.org/#dom-node-textcontent

test case: http://w3c-test.org/dom/nodes/DOMImplementation-createHTMLDocument.html
test name: DOMImplementation.createHTMLDocument
Comment 1 Kangil Han 2014-07-01 15:03:53 UTC
For the information,(alphabetical order)
  chrome: fail
  ff: pass
  ie: fail
Comment 2 Olli Pettay 2014-07-01 15:17:41 UTC
What is exactly confusing? 
textnode.data = ""; sets text node's content to "".
element.textContent = ""; removes all the child nodes.
element.textContent = "foo"; removes all the child nodes and 
creates a text node with data "foo" and appends it to element.
Comment 3 Boris Zbarsky 2014-07-01 15:50:14 UTC
Basically, createHTMLDocument("foo") does NOT set .textContent = "foo" on the <title> element.  It does something slightly different that guarantees there is a text node inside that <title>.

Looking at Chrome's code, it implements createHTMLDocument("foo") by doing:

  document.title = "foo";

which is defined in the spec in terms of setting textContent on the <title> element, which in fact does not match what the DOM spec says to do for createHTMLDocument.
Comment 4 Ms2ger 2014-07-01 19:25:50 UTC
(In reply to Kangil Han from comment #1)
> For the information,(alphabetical order)
>   chrome: fail
>   ff: pass
>   ie: fail

Servo: pass
Comment 5 Anne 2014-07-01 19:45:32 UTC
The specification does not seem confusing, but I guess comment 0 is actually asking if we want to align the two cases. I have no opinion really.
Comment 6 Kangil Han 2014-07-02 09:19:15 UTC
Thanks for comments!
I am fixing chromium behavior as per comment 3 suggested by Boris.
https://codereview.chromium.org/366883003/