<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>7842</bug_id>
          
          <creation_ts>2009-10-08 13:32:33 +0000</creation_ts>
          <short_desc>No programmatic way to make an HTML document - consider adding createHTMLDocument</short_desc>
          <delta_ts>2010-10-04 14:49:27 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>pre-LC1 HTML5 spec (editor: Ian Hickson)</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>NE</keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Maciej Stachowiak">mjs</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>hsivonen</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>28129</commentid>
    <comment_count>0</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2009-10-08 13:32:33 +0000</bug_when>
    <thetext>Problem:
With the combination of HTML5, and DOM APIs, there is a programmatic way to make a brand new empty XML document (DOMImplementation.createDocument), but no way to make an HTML document other than by action of the parser. This seems like an unfortunate gap.

Possible solution: 
It turns out that an old draft of DOM2 HTML included an HTMLDOMImplementation interface with a createHTMLDocument() method - intended to be implemented on the DOMImplementation object. WebKit and Presto implement it. Without this method, there is no programmatic way to make an HTML document; you have to use the parser. Since HTML5 takes over where DOM2HTML left off, I think it would be a good idea to add this method back.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>28130</commentid>
    <comment_count>1</comment_count>
    <who name="Henri Sivonen">hsivonen</who>
    <bug_when>2009-10-08 13:41:37 +0000</bug_when>
    <thetext>Relevant email:
http://lists.w3.org/Archives/Public/www-dom/2009OctDec/0022.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>28135</commentid>
    <comment_count>2</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2009-10-08 15:30:07 +0000</bug_when>
    <thetext>Both Opera and WebKit create a document with the HTMLness bit set, implements the HTMLDocument interface, and uses standards mode.

WebKit uses a doctype (with name &apos;html&apos; and publicId and systemId returning the empty string), Opera doesn&apos;t. The document has the html, head, title and body elements. In Opera, the title always has a text node child. In WebKit, it only has a text node child if the argument wasn&apos;t the empty string. If the argument is omitted, Opera throws a WRONG_ARGUMENTS_ERR internal exception and WebKit sets the title to &apos;undefined&apos; (i.e. it&apos;s not &apos;optional&apos; in the IDL).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>28552</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2009-10-20 09:05:10 +0000</bug_when>
    <thetext>What&apos;s the use case?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>28557</commentid>
    <comment_count>4</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2009-10-20 09:44:40 +0000</bug_when>
    <thetext>Same as the use case for creating a document programatically in general, in cases where it&apos;s useful to have some processing where the HTMLness bit matters. Some potential (maybe contrived) examples:

- Create a non-rendered HTML document to upload via XMLHttpRequest (instead of sending an XML document).

- Feature-test the HTML DOM in library code in a way that is guaranteed to avoid side effects on the displayed document.

- Create an isolated non-rendered document from a rich text editing area, so client-side cleanup can be done before uploading without disturbing the live DOM that the user may still edit further.

- Implement HTML5 parsing algorithm client-side in JavaScript for testing and comparison purposes, or for virtualization or object-capability-based security.

 An invisible iframe can be used for most of these purposes but that is more expensive in terms of resources.

I think these use cases are not necessarily the most compelling. Mainly it seems non-orthogonal that HTML documents can only be created by the HTML parser, and thus offscreen / non-rendered documents all have to be XML documents. This seems like an unnecessary asymmetry.

Reopening for consideration of provided info.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>28571</commentid>
    <comment_count>5</comment_count>
    <who name="">contributor</who>
    <bug_when>2009-10-20 11:13:56 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r4207.
Check-in comment: Define createHTMLDocument().
http://html5.org/tools/web-apps-tracker?from=4206&amp;to=4207
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>28907</commentid>
    <comment_count>6</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2009-10-23 22:28:36 +0000</bug_when>
    <thetext>Looks good to me.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>