<?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>24645</bug_id>
          
          <creation_ts>2014-02-13 07:16:02 +0000</creation_ts>
          <short_desc>li should provide DOM interface to its rendered value representation</short_desc>
          <delta_ts>2016-03-16 14:33:26 +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>DUPLICATE</resolution>
          <dup_id>17632</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>blocked awaiting response to comment 7 (please remove this when replying)</status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          <dependson>24644</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Silvia Pfeiffer">silviapfeiffer1</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>annevk</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>felipenmoura</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
    
    <cc>w3c</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>100466</commentid>
    <comment_count>0</comment_count>
    <who name="Silvia Pfeiffer">silviapfeiffer1</who>
    <bug_when>2014-02-13 07:16:02 +0000</bug_when>
    <thetext>+++ This bug was initially created as a clone of Bug #24644 +++

&lt;li&gt; children of &lt;ol&gt; (and less significantly &lt;ul&gt;) may have a list marker rendered next to them. For children of &lt;ol&gt; the value of this marker can be set explicitly with the value attribute.

When the value is not set (including because it is not a child of &lt;ol&gt;) the user agent will automatically determine and render a marker, if applicable in accordance with the CSS rules applied to the element.

The automatically determined (or rendered) value is not DOM-accessible.

I propose that the DOM interface for li elements be expanded to include a new property:

  readonly attribute Node? renderedValue;

This would return an Element or Text node, being the automatically calculated value for that li (or null if no list marker is rendered).

In the alternative, this could be only available for li children of ol elements:

  readonly attribute long ordinalValue;

being the ordinal value &lt;http://www.w3.org/html/wg/drafts/html/master/grouping-content.html#ordinal-value&gt; of the li element.

My suggestion is that the value is readonly to simplify implementation.

The most obvious use case for this property is cross-referencing in documents, for example where paragraphs are numbered.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100467</commentid>
    <comment_count>1</comment_count>
    <who name="Silvia Pfeiffer">silviapfeiffer1</who>
    <bug_when>2014-02-13 07:25:49 +0000</bug_when>
    <thetext>I just checked in Chrome and a &lt;li&gt; inside a &lt;ol&gt; without a content value attribute ends up always having li.value=0 , which agree to be confusing. Curious about thoughts on this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100632</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-02-14 21:49:35 +0000</bug_when>
    <thetext>In what sense is it not DOM accessible? The spec defines exactly what the value is for any &lt;li&gt;, no?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100656</commentid>
    <comment_count>3</comment_count>
    <who name="Silvia Pfeiffer">silviapfeiffer1</who>
    <bug_when>2014-02-14 23:45:01 +0000</bug_when>
    <thetext>(In reply to Ian &apos;Hixie&apos; Hickson from comment #2)
&gt; In what sense is it not DOM accessible? The spec defines exactly what the
&gt; value is for any &lt;li&gt;, no?

The rendered value is not the same as the value presented to the developer in .value when no @value attribute is given. I confirmed this in Chrome and Firefox, see http://html5videoguide.net/test/test_ol.html .

I believe the spec explains clearly what the browser needs to render as a number (described in the ol and li element sections). It also clearly states that the value IDL attribute must reflect the value of @value.

If, however, no @value is present, then the value IDL attribute&apos;s value is not defined (FAICT) and ends up being 0, even when the browser renders an actual number.

I assume that would be a problem in a JS lib that wants to make use of the rendered value.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>101019</commentid>
    <comment_count>4</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-02-20 20:58:45 +0000</bug_when>
    <thetext>li.value is just the IDL attribute reflecting the content attribute; if the content attribute is absent, then it returns 0.

If a JS library wants to know the ordinal value of a list item, right now, they have to compute it (we don&apos;t have an API that exposes it). The information to compute it is all in the DOM. We could add an API to make this simpler, but what&apos;s the use case, exactly? It would save a half-dozen lines of code maybe, so unless it&apos;s something that is needed a lot, it doesn&apos;t seem worth it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>101166</commentid>
    <comment_count>5</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-02-21 22:40:58 +0000</bug_when>
    <thetext>Please reopen if there&apos;s a compelling use case for a dedicated API for getting the ordinal value of a list item.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>101739</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Cordover">w3c</who>
    <bug_when>2014-03-03 03:26:38 +0000</bug_when>
    <thetext>Copied from comments on bug #24644 per Silvia Pfeiffer at comment 4 on that bug:

(In reply to Silvia Pfeiffer)
&gt; (In reply to Michael Cordover)
&gt; &gt;
&gt; &gt; The most obvious use case for this property is cross-referencing in
&gt; &gt; documents, for example where paragraphs are numbered.
&gt; 
&gt; Michael, could you explain your use case in a bit more detail?
&gt; 
&gt; In the discussion in bug 24645 the suggestion was to compute the ordinal
&gt; value of a list item from all the information available in the DOM. It&apos;s
&gt; only a few lines of code (basically: ol.childNodes and then count only those
&gt; with tagName=&quot;LI&quot;). Why would that not be sufficient for you?

There are a couple of issues I have with this. One is that it&apos;s not quite that simple: you need to also take into account ol.start at least, plus ol.reversed and any other innovations in future specs. To get the rendered value you also have to consider the style.

I also don&apos;t think it&apos;s the responsibility of the content author to replicate work already done by the UA.

Most importantly though the information presented by the UA has semantic value. That&apos;s the basis for the distinction between ul and ol. I think that semantic information should be DOM-accessible as a matter of principle.

In terms of use case, I&apos;m thinking about cross-referencing in documents e.g. &quot;refer to clause X&quot; scenarios. For example:

HTML:
  &lt;ol&gt;
    &lt;li&gt;A legal clause&lt;/li&gt;
    &lt;li id=&quot;c&quot;&gt;Another legal clause about copyright&lt;/li&gt;
    &lt;li&gt;Except in accordance with &lt;a class=&quot;xref&quot; href=&quot;#c&quot;&gt;the copyright clause&lt;/a&gt;...&lt;/li&gt;
  &lt;/ol&gt;

JS:
  var x = document.getElementsByClassName(&quot;xref&quot;)[0];
  x.textContent = &quot;clause &quot; + document.getElementById(x.href.substring(1)).ordinalValue.toString();</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>101766</commentid>
    <comment_count>7</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-03-03 19:02:43 +0000</bug_when>
    <thetext>For the cross-reference case, I think you really want a CSS solution, at least on the long term, because you want to be able to handle things like page numbers too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125531</commentid>
    <comment_count>8</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2016-03-16 14:33:26 +0000</bug_when>
    <thetext>If anything this will be done through a CSS API.

*** This bug has been marked as a duplicate of bug 17632 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>