<?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>17743</bug_id>
          
          <creation_ts>2012-07-11 12:12:15 +0000</creation_ts>
          <short_desc>When setting designMode to &apos;on&apos;, the selection should be moved to an empty selection at the start of body (or something like that). If there isn&apos;t a body yet, wait until there is. Don&apos;t do this for contenteditable.</short_desc>
          <delta_ts>2016-02-04 07:21:59 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>HISTORICAL - HTML Editing APIs</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#making-entire-documents-editable:-the-designmode-idl-attribute</bug_file_loc>
          <status_whiteboard>whatwg-resolved</status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Aryeh Gregor">ayg</assigned_to>
          <cc>ayg</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>Ms2ger</cc>
    
    <cc>philipj</cc>
    
    <cc>public-webapps</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact name="HTML Editing APIs spec bugbot">sideshowbarker+html-editing-api</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>69831</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2012-07-11 12:12:15 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html
Multipage: http://www.whatwg.org/C#making-entire-documents-editable:-the-designmode-idl-attribute
Complete: http://www.whatwg.org/c#making-entire-documents-editable:-the-designmode-idl-attribute

Comment:
When setting designMode to &apos;on&apos;, the selection should be moved to an empty
selection at the start of body (or something like that). If there isn&apos;t a body
yet, wait until there is. Don&apos;t do this for contenteditable.

Posted from: 2001:4c28:a030:30:3974:4eac:84c6:cfd6 by simonp@opera.com
User agent: Opera/9.80 (Macintosh; Intel Mac OS X 10.7.3; U; en) Presto/2.10.289 Version/12.00</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71054</commentid>
    <comment_count>1</comment_count>
    <who name="">contributor</who>
    <bug_when>2012-07-18 17:59:36 +0000</bug_when>
    <thetext>This bug was cloned to create bug 18294 as part of operation convergence.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71551</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-07-26 23:50:38 +0000</bug_when>
    <thetext>I don&apos;t disagree in principle, but can you elaborate? Is this to match implementations? (Are there tests I can look at?) For some other reason?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>72114</commentid>
    <comment_count>3</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2012-08-13 10:25:37 +0000</bug_when>
    <thetext>Opera sets caret for contenteditable, but other browsers don&apos;t, and this caused us some problems with some editors. Everybody sets the caret for designMode. Since some pages set designMode to &apos;on&apos; before there is a &lt;body&gt;, we need to wait with setting the caret (but shouldn&apos;t wait for window.onload since that can take too long). Browsers do this but aren&apos;t fuilly interoperable. I don&apos;t have tests at hand currently.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75904</commentid>
    <comment_count>4</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-10-10 23:43:18 +0000</bug_when>
    <thetext>Aryeh, do you have any input here?

Simon, my proposal is that when designMode is set to true, the root element (which is what becomes an editing host) be focus()ed, and the Selection is set to a collapsed range at the root element&apos;s start. (Will that result in content going into the &lt;body&gt; when the user types?) I&apos;ll put this in the HTML spec unless Aryeh wants it in the HTML Editing APIs spec, but I think HTML is the right place for it since that&apos;s where designMode is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75942</commentid>
    <comment_count>5</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2012-10-11 06:57:30 +0000</bug_when>
    <thetext>(In reply to comment #4)
&gt; Aryeh, do you have any input here?

Not really.  I never tested designMode much.  For one thing, it&apos;s a pain, because some browsers refuse to run script after you set designMode to on, and if you do it in an iframe I don&apos;t know if the selection/focus behavior will be the same.

&gt; Simon, my proposal is that when designMode is set to true, the root element
&gt; (which is what becomes an editing host) be focus()ed, and the Selection is
&gt; set to a collapsed range at the root element&apos;s start. (Will that result in
&gt; content going into the &lt;body&gt; when the user types?)

Per my current spec, no -- I have no special handling of root element vs. body at the moment, so it will go in the root element before the &lt;head&gt;.  In practice, maybe yes, I don&apos;t know.  I focused almost exclusively on contenteditable, so I didn&apos;t bother spending time on the case where the root element is editable (which is not how contenteditable is normally used).  In real life, designMode predated contenteditable (I think -- at least in Gecko) and browsers may well have special cases for stuff like this.

But I&apos;m guessing that if Simon said you need to wait for the body to exist, he had a reason for wanting the extra complexity instead of just saying to put it in the root element (which will exist under any normal circumstances).

&gt; I&apos;ll put this in the
&gt; HTML spec unless Aryeh wants it in the HTML Editing APIs spec, but I think
&gt; HTML is the right place for it since that&apos;s where designMode is.

Please feel free to take it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75951</commentid>
    <comment_count>6</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2012-10-11 09:40:10 +0000</bug_when>
    <thetext>The waiting behavior appears to be browsers&apos; current behavior from my ad-hoc testing, however I don&apos;t mind putting the selection at the start of the root element and have the editing spec special case the root element. We need to handle &lt;html contenteditable&gt; anyway.

The only problem I see with allowing editing before the body has been parsed is what should happen if the user starts typing before body exists? (This could happen with contenteditable too.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76016</commentid>
    <comment_count>7</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-10-11 17:30:52 +0000</bug_when>
    <thetext>What happens today with &lt;html contenteditable&gt; if there&apos;s no &lt;body&gt;, or if one is added later? Maybe there&apos;s less magic here than we think.

designMode can be set on a document without a body parsed yet; can the user not focus it manually in that case and start typing? e.g. if designMode is set during parse, and there&apos;s a minute delay between the &lt;/head&gt; and the &lt;body&gt;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76530</commentid>
    <comment_count>8</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-10-17 22:56:05 +0000</bug_when>
    <thetext>zcorpan: ping</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76561</commentid>
    <comment_count>9</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2012-10-18 07:40:17 +0000</bug_when>
    <thetext>http://simon.html5.org/dump/html-contenteditable-sleep.php
http://simon.html5.org/dump/html-designMode-sleep.php

Firefox/Chrome/Opera don&apos;t start rendering the page at all before there&apos;s a body element.

http://simon.html5.org/dump/html-contenteditable-remove-body.html

Firefox/Chrome/Opera don&apos;t allow editing at all when the body element is removed. (Firefox shows a caret but typing doesn&apos;t insert text.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76605</commentid>
    <comment_count>10</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-10-18 19:02:50 +0000</bug_when>
    <thetext>Are you sure you&apos;re not getting server-side buffering?

curl -N http://simon.html5.org/dump/html-contenteditable-sleep.php

...doesn&apos;t return anything for me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76652</commentid>
    <comment_count>11</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2012-10-19 06:51:57 +0000</bug_when>
    <thetext>Sigh. Well, http://simon.html5.org/dump/html-contenteditable-remove-body.html makes that moot anyway.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76750</commentid>
    <comment_count>12</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-10-19 20:18:05 +0000</bug_when>
    <thetext>http://simon.html5.org/dump/html-contenteditable-remove-body.html in Chrome lets me keep typing after the &lt;body&gt; is removed, so long as I focus it first. I think that&apos;s got more to do with focusing without &lt;body&gt; than contenteditable.

Anyway, in conclusion, I think comment 4 is still the right solution.

Aryeh&apos;s spec probably needs to handle the missing &lt;body&gt; case as well though. (Separate bug, probably.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82186</commentid>
    <comment_count>13</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-01-26 05:44:37 +0000</bug_when>
    <thetext>Aryeh, do you want to use this bug to track how to handle editing when there&apos;s no &lt;body&gt;? Or do you want a new bug? (Either way, I recommend making it so that if the user tries to modify a doc with no &lt;body&gt;, nothing happens, and if they try to modify a document with a &lt;body&gt; while the caret or active range are outside the &lt;body&gt;, they get snapped to the &lt;body&gt; first.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82187</commentid>
    <comment_count>14</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-01-26 05:44:56 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r7660.
Check-in comment: Define designMode to set focus and selection.
http://html5.org/tools/web-apps-tracker?from=7659&amp;to=7660</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82196</commentid>
    <comment_count>15</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2013-01-26 11:34:32 +0000</bug_when>
    <thetext>Simon, want to write some automated tests? :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82473</commentid>
    <comment_count>16</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2013-02-01 12:51:41 +0000</bug_when>
    <thetext>(In reply to comment #13)
&gt; Aryeh, do you want to use this bug to track how to handle editing when
&gt; there&apos;s no &lt;body&gt;? Or do you want a new bug? (Either way, I recommend making
&gt; it so that if the user tries to modify a doc with no &lt;body&gt;, nothing
&gt; happens, and if they try to modify a document with a &lt;body&gt; while the caret
&gt; or active range are outside the &lt;body&gt;, they get snapped to the &lt;body&gt;
&gt; first.)

I&apos;m not actively maintaining the editing spec now -- so incidentally, you can take it if you want.  I specifically didn&apos;t pay much attention to edge cases like no &lt;body&gt; when writing the editing spec, because there&apos;s enough work to do on interop in important cases.  I think that in the current spec, execCommand() will probably do nothing if the selection doesn&apos;t contain any editable visible nodes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84870</commentid>
    <comment_count>17</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-03-22 18:17:32 +0000</bug_when>
    <thetext>Ok, I&apos;ll move this to the HTML Editing APIs component and whoever ends up taking that over (could be me, we&apos;ll see if I get out from under this pile of feedback) can deal with it.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>