<?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>11554</bug_id>
          
          <creation_ts>2010-12-15 08:37:30 +0000</creation_ts>
          <short_desc>:read-write selector spec is ambiguous on editable input/textarea fields</short_desc>
          <delta_ts>2011-08-04 05:15:04 +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>LC1 HTML5 spec</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://dev.w3.org/html5/spec/Overview.html#selector-read-write</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="Ehsan Akhgari [:ehsan]">ehsan</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>bzbarsky</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>mounir</cc>
    
    <cc>Ms2ger</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>43373</commentid>
    <comment_count>0</comment_count>
    <who name="Ehsan Akhgari [:ehsan]">ehsan</who>
    <bug_when>2010-12-15 08:37:30 +0000</bug_when>
    <thetext>Please see the :read-write selector in the current version of the spec.  To quote it here:

The :read-write pseudo-class must match the following elements:

   * input elements to which the readonly attribute applies, but that are not immutable (i.e. that do not have the readonly attribute specified and that are not disabled)
   * textarea elements that do not have a readonly attribute, and that are not disabled
   * any element that is editable

I find it really hard to determine whether this means that :read-write should match the input element in the following markup or not:

&lt;div contenteditable=&quot;true&quot;&gt;
  &lt;input readonly&gt;
&lt;/div&gt;

I would expect the logical thing to do here would be to make it match :read-only, which is what would be inferred from the spec if the bullet point list above is interpreted as a set of if-else conditions.  But I think we should be more specific here anyways.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43377</commentid>
    <comment_count>1</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2010-12-15 13:44:19 +0000</bug_when>
    <thetext>(In reply to comment #0)
&gt; The :read-write pseudo-class must match the following elements:
&gt; 
&gt;    * input elements to which the readonly attribute applies, but that are not
&gt; immutable (i.e. that do not have the readonly attribute specified and that are
&gt; not disabled)

Doesn&apos;t apply, as the readonly attribute is present.

&gt;    * textarea elements that do not have a readonly attribute, and that are not
&gt; disabled

Doesn&apos;t apply, as it isn&apos;t a textarea.

&gt;    * any element that is editable

&quot;editable&quot; is defined as follows:

&gt; Specifically, if an HTML element has a contenteditable attribute set to the
&gt; true state, or *it has its contenteditable attribute set to the inherit state
&gt; and if its nearest ancestor HTML element with the contenteditable attribute
&gt; set to a state other than the inherit state has its attribute set to the
&gt; true state,* or if it and its ancestors all have their contenteditable
&gt; attribute set to the inherit state but the Document has designMode enabled,
&gt; then the UA must treat the element as *editable* (as described below).

The input has no contenteditable attribute, so it is in the /missing value default/ state, which is /inherit/. Its parent has a contenteditable attribute in the /true/ state, so the clause I emphasised above applies. Thus, the element is &quot;editable&quot;.

This clause applies, so :read-write matches.

&gt; 
&gt; I find it really hard to determine whether this means that :read-write should
&gt; match the input element in the following markup or not:
&gt; 
&gt; &lt;div contenteditable=&quot;true&quot;&gt;
&gt;   &lt;input readonly&gt;
&gt; &lt;/div&gt;
&gt; 
&gt; I would expect the logical thing to do here would be to make it match
&gt; :read-only, which is what would be inferred from the spec if the bullet point
&gt; list above is interpreted as a set of if-else conditions.  But I think we
&gt; should be more specific here anyways.

IMHO, it is sufficiently clear. In pseudo-code, the bullet points would read

bool IsReadWrite(Element* e) {
  if (e-&gt;IsHTML(&quot;input&quot;) &amp;&amp; e-&gt;ReadonlyApplies() &amp;&amp; !e-&gt;Immutable())
    return true;
  if (e-&gt;IsHTML(&quot;textarea&quot;) &amp;&amp; !e-&gt;HasAttr(&quot;readonly&quot;) &amp;&amp; !e-&gt;Disabled()
    return true;
  if (e-&gt;Editable())
    return true;
  return false;
}
bool IsReadOnly(Element* e) {
  return e-&gt;IsHTML() &amp;&amp; !IsReadWrite(e);
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43398</commentid>
    <comment_count>2</comment_count>
    <who name="Ehsan Akhgari [:ehsan]">ehsan</who>
    <bug_when>2010-12-15 16:03:12 +0000</bug_when>
    <thetext>So, is this intentional for readonly input elements to match :read-write?  Should the UA allow the user to treat them as editable controls, as if they had no readonly property to begin with?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43399</commentid>
    <comment_count>3</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2010-12-15 16:33:14 +0000</bug_when>
    <thetext>&gt; IMHO, it is sufficiently clear.

No, it&apos;s not (as evidenced by at least two smart people getting confused by it so far!).  What would be sufficiently clear is:

  The :read-write pseudo-class must match elements that satisfy any of the
  following conditions:

followed by a list of conditions.  If you mean something, just say what you mean instead of implying it!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43402</commentid>
    <comment_count>4</comment_count>
    <who name="Mounir Lamouri">mounir</who>
    <bug_when>2010-12-15 17:21:25 +0000</bug_when>
    <thetext>So, according to the specs, the input in this case has :read-write applying:
&lt;div contenteditable&gt;
  &lt;input readonly disabled&gt;
&lt;/diw&gt;

Is this input&apos;s value modifiable by the user? I would say no, at least because of the disabled attribute [1]. So, we have an element matching :read-write but is technically read-only. Do we really want to do that?

Can&apos;t we have this list changed to this:

   * If the elemnet is an input element to which the readonly attribute applies, but that are not immutable (i.e. that do not have the readonly attribute specified and that are not disabled)
   * If the element is a textarea element that do not have a readonly attribute, and that are not disabled
   * If the element is not an input element nor a textarea element and is editable

That way, the input element in the previous code will be read-only and match :read-only.

[1] http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#enabling-and-disabling-form-controls</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43426</commentid>
    <comment_count>5</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2010-12-16 13:15:57 +0000</bug_when>
    <thetext>I&apos;m not sure how else &quot;The :read-write pseudo-class must match the following elements:&quot; would be read than as the intersection of the sets defined by each bullet point.

Also, IMO, it makes sense for the input to be :read-write as, despite not being able to type *into* the input, one can delete the entire input.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43427</commentid>
    <comment_count>6</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2010-12-16 13:17:11 +0000</bug_when>
    <thetext>(In reply to comment #5)
&gt; as the intersection

The union, I should say.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43435</commentid>
    <comment_count>7</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2010-12-16 17:34:56 +0000</bug_when>
    <thetext>&gt; I&apos;m not sure how else &quot;The :read-write pseudo-class must match the following
&gt; elements:&quot; would be read

Other places the spec uses similar wording for if/else cascades (which is how I believe Mounir read it) or conditions that need to be anded as opposed to or&apos;ed.

Seriously, just being explicit about which set operations should be applied to the sets defined by the conditions instead of writing something that implies something and then hoping that everyone, including non-native-English-speakers will properly understand your implications seems like a no-brainer to me....</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43511</commentid>
    <comment_count>8</comment_count>
    <who name="Mounir Lamouri">mounir</who>
    <bug_when>2010-12-21 21:04:29 +0000</bug_when>
    <thetext>(In reply to comment #5)
&gt; Also, IMO, it makes sense for the input to be :read-write as, despite not being
&gt; able to type *into* the input, one can delete the entire input.

Being able to delete the input doesn&apos;t mean you can write into it/modify it. That is how I was seeing :read-write but I guess you can consider that deleting is already a form of interaction...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>44204</commentid>
    <comment_count>9</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-01-11 19:51:35 +0000</bug_when>
    <thetext>EDITOR&apos;S RESPONSE: This is an Editor&apos;s Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see diff given below
Rationale:

Apologies for the weak text. I&apos;ve tightened it up.

I&apos;ve also made whether inputs and textareas match :read-write not get affected by whether they&apos;re inside editing hosts.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>44205</commentid>
    <comment_count>10</comment_count>
    <who name="">contributor</who>
    <bug_when>2011-01-11 19:51:45 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r5769.
Check-in comment: clarify :read-write
http://html5.org/tools/web-apps-tracker?from=5768&amp;to=5769</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>53558</commentid>
    <comment_count>11</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2011-08-04 05:15:04 +0000</bug_when>
    <thetext>mass-move component to LC1</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>