<?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>26005</bug_id>
          
          <creation_ts>2014-06-06 17:03:00 +0000</creation_ts>
          <short_desc>Selection.extend behavior when there is no range needs to be clarified</short_desc>
          <delta_ts>2014-09-16 01:18:58 +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 - Selection API</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ben Peters">benjamp</reporter>
          <assigned_to name="Ryosuke Niwa">rniwa</assigned_to>
          <cc>benjamp</cc>
    
    <cc>public-webapps</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>107438</commentid>
    <comment_count>0</comment_count>
    <who name="Ben Peters">benjamp</who>
    <bug_when>2014-06-06 17:03:00 +0000</bug_when>
    <thetext>Today, the Selection API spec seems to say that if selection.rangeCount is 0, then selection.extend should throw an error and abort. This is true in Firefox, but not Chrome. In Chrome, it appears that a new collapsed range is created at the position specified in selection.extend. Without an error, it&apos;s possible a site might end up creating a selection when they think they&apos;re extending it. But errors in JS should be used sparingly. Not sure which of these makes more sense.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109974</commentid>
    <comment_count>1</comment_count>
    <who name="Ben Peters">benjamp</who>
    <bug_when>2014-08-05 22:49:18 +0000</bug_when>
    <thetext>Proposed text, based on the text for collapse():

void setBaseAndExtent (Node baseNode, unsigned long baseOffset, Node extentNode, unsigned long extentOffset);

The method must throw an IndexSizeError exception if offset is negative or longer than node&apos;s length ([DOM4]). Otherwise, it must create a new range, set ([DOM4]) its start to (baseNode, baseOffset) and its and end to (extentNode, extentOffset), and set the context object&apos;s range to the newly-created range.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109975</commentid>
    <comment_count>2</comment_count>
    <who name="Ben Peters">benjamp</who>
    <bug_when>2014-08-05 22:52:03 +0000</bug_when>
    <thetext>Ignore the last comment, Bugzilla was having login trouble that caused it to post to the wrong bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111569</commentid>
    <comment_count>3</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2014-09-16 01:18:58 +0000</bug_when>
    <thetext>(In reply to Ben Peters from comment #0)
&gt; Today, the Selection API spec seems to say that if selection.rangeCount is
&gt; 0, then selection.extend should throw an error and abort. This is true in
&gt; Firefox, but not Chrome. In Chrome, it appears that a new collapsed range is
&gt; created at the position specified in selection.extend. Without an error,
&gt; it&apos;s possible a site might end up creating a selection when they think
&gt; they&apos;re extending it. But errors in JS should be used sparingly. Not sure
&gt; which of these makes more sense.

This is taken care of by the first step in its definition:

&quot;If the context object is empty, throw an InvalidStateError exception and abort these steps.&quot;

since the definition of &quot;empty&quot; is

&quot;Each selection can be associated with a single range (defined in [DOM4]). When there is no range associated with the selection, the selection is empty. The selection must be initially empty.&quot;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>