<?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>20171</bug_id>
          
          <creation_ts>2012-11-30 12:11:51 +0000</creation_ts>
          <short_desc>There is no clear statement when APIs for the text field selections can be applied</short_desc>
          <delta_ts>2013-02-11 17:09:42 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Egor Khalimonenko">termi1uc1</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>ian</cc>
    
    <cc>mike</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>79178</commentid>
    <comment_count>0</comment_count>
      <attachid>1251</attachid>
    <who name="Egor Khalimonenko">termi1uc1</who>
    <bug_when>2012-11-30 12:11:51 +0000</bug_when>
    <thetext>Created attachment 1251
Different behavour between {FireFox, Opera} and Chrome

Spec say: &quot;For input elements, calling these methods while they don&apos;t apply, and getting or setting these attributes while they don&apos;t apply, must throw an InvalidStateError exception.&quot;
No browser has implemented InvalidStateError error. And the is no clear statement, that does &quot;while they don&apos;t apply&quot; mean.

Can we call element.setSelectionRange while element has no focus?

The are two different model in browsers I tested:

1. FireFox and Opera, set selectionStart and selectionStart values without setting focus.
2. Chrome, set selectionStart and selectionStart values with setting focus to current element.

Both behavior seams wrong. But Chrome behavior is worse, due it broke events queue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82858</commentid>
    <comment_count>1</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-02-09 21:35:15 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r7716.
Check-in comment: Clarify &apos;do not apply&apos;.
http://html5.org/tools/web-apps-tracker?from=7715&amp;to=7716</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82859</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-02-09 21:56:35 +0000</bug_when>
    <thetext>&gt; attachment 1251

Looks like Opera&apos;s the one that gets this right.


&gt; Spec say: &quot;For input elements, calling these methods while they don&apos;t apply,
&gt; and getting or setting these attributes while they don&apos;t apply, must throw
&gt; an InvalidStateError exception.&quot;
&gt; No browser has implemented InvalidStateError error.

They vary in what exception they throw, but I got an exception in all the browsers I tested (Firefox, Chrome, Opera) on this test:
   http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2090


&gt; And the is no clear statement, that does &quot;while they don&apos;t apply&quot; mean.

I&apos;ve hyperlinked it to a clearer definition. Let me know if it&apos;s still not clear.


&gt; Can we call element.setSelectionRange while element has no focus?

Sure, the spec doesn&apos;t say anything about focus having an effect here.


&gt; The are two different model in browsers I tested:
&gt; 
&gt; 1. FireFox and Opera, set selectionStart and selectionStart values without
&gt; setting focus.
&gt; 2. Chrome, set selectionStart and selectionStart values with setting focus
&gt; to current element.
&gt; 
&gt; Both behavior seams wrong. But Chrome behavior is worse, due it broke events
&gt; queue.

Chrome definitely is wrong here, yes. Please file a bug on Chrome!


Let me know (by commenting on this bug and reopening it) if you see anything wrong in the spec at this point. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82914</commentid>
    <comment_count>3</comment_count>
    <who name="Egor Khalimonenko">termi1uc1</who>
    <bug_when>2013-02-11 17:09:42 +0000</bug_when>
    <thetext>There was a misunderstanding due I don&apos;t specify the type of input. My original question was about &apos;input type=text&apos; or &apos;textarea&apos;. I was frustrated by Chrome behavior and Spec was the last hope to understand the right behavior.

But it&apos;s still unclean for me. Can browser apply setSelectionRange on input[type=text] element that doesn&apos;t have focus? I guess it depend on browser, but Spec need to say something about it. Something like: &quot;User agent can apply selectionRange methods on inactive input element, but without changing current active input element&quot;.

And thanks for http://html5.org/r/7716 clarification, it&apos;s important for me too.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>1251</attachid>
            <date>2012-11-30 12:11:51 +0000</date>
            <delta_ts>2012-11-30 12:11:51 +0000</delta_ts>
            <desc>Different behavour between {FireFox, Opera} and Chrome</desc>
            <filename>Chrome_input_focus_BUG2.html</filename>
            <type>text/html</type>
            <size>1514</size>
            <attacher name="Egor Khalimonenko">termi1uc1</attacher>
            
              <data encoding="base64">77u/PCFET0NUWVBFIEhUTUw+DQo8aHRtbD4NCjxoZWFkPg0KICA8bWV0YSBjaGFyc2V0PSJ1dGYt
OCI+DQo8L2hlYWQ+DQo8Ym9keT4NCg0KICA8cD5UaGVyZSBzaG91ZCBiZSBubyBmb2N1c2VkIGVs
ZW1lbnRzPC9wPg0KICA8Zm9ybSBpZD0iZm9ybSI+DQogICAgICA8bGFiZWwgc3R5bGU9ImRpc3Bs
YXk6YmxvY2siPg0KICAgICAgICAgIDxpbnB1dCAvPg0KCQkgIDxzcGFuPkxhc3QgZXZlbnQ6IDxi
PjwvYj4NCiAgICAgIDwvbGFiZWw+DQogICAgICA8bGFiZWwgc3R5bGU9ImRpc3BsYXk6YmxvY2si
Pg0KICAgICAgICAgIDxpbnB1dCAvPg0KCQkgIDxzcGFuPkxhc3QgZXZlbnQ6IDxiPjwvYj4NCiAg
ICAgIDwvbGFiZWw+DQogICAgICA8bGFiZWwgc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