<?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>17201</bug_id>
          
          <creation_ts>2012-05-25 23:23:42 +0000</creation_ts>
          <short_desc>HTMLCollection.prototype.namedItem behavior not defined for HTMLPropertiesCollection</short_desc>
          <delta_ts>2013-04-29 23:09:05 +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>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#htmlpropertiescollection-0</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          <dependson>20225</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>bzbarsky</cc>
    
    <cc>cam</cc>
    
    <cc>dzbarsky</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>Ms2ger</cc>
    
    <cc>www-dom</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>68172</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2012-05-25 23:23:42 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html
Multipage: http://www.whatwg.org/C#htmlpropertiescollection-0
Complete: http://www.whatwg.org/c#htmlpropertiescollection-0

Comment:
HTMLCollection.prototype.namedItem behavior not defined for
HTMLPropertiesCollection

Posted from: 71.184.125.56 by bzbarsky@mit.edu
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:15.0) Gecko/15.0 Firefox/15.0a1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>68173</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2012-05-25 23:26:19 +0000</bug_when>
    <thetext>In particular, the spec for HTMLPropertiesCollection says:

    legacycaller getter PropertyNodeList? namedItem(DOMString name); // overrides inherited namedItem()

But the &quot;inherited&quot; namedItem can still be applied to HTMLPropertiesCollection objects, and the behavior of that needs to be defined.  HTMLCollection says in an informative note:

  The namedItem() method returns an object for interfaces that inherit from this
  interface, which return other objects for historical reasons. 

and the IDL is:

    getter object? namedItem(DOMString name);

so what you probably want to do here is not override it at all and just say in normative prose that the object returned, if any, is a PropertyNodeList.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>68175</commentid>
    <comment_count>2</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2012-05-25 23:29:36 +0000</bug_when>
    <thetext>Note that the Gecko implementation will be assuming the spec is fixed as I suggest.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>70857</commentid>
    <comment_count>3</comment_count>
    <who name="">contributor</who>
    <bug_when>2012-07-18 17:38:16 +0000</bug_when>
    <thetext>This bug was cloned to create bug 18195 as part of operation convergence.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>72781</commentid>
    <comment_count>4</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-08-26 03:11:50 +0000</bug_when>
    <thetext>heycam, can I get me some IDL love to describe this? An &quot;override&quot; keyword for example, whose semantic would be &quot;the prose for this operation defines what the inherited operation does when applied to objects implementing this interface, overriding the superclass&apos; definition&quot;, with the requirement that the signatures be identical or that the subclass&apos; signature be a subset (as here)?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>72872</commentid>
    <comment_count>5</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2012-08-27 23:46:37 +0000</bug_when>
    <thetext>(In reply to comment #4)
&gt; heycam, can I get me some IDL love to describe this? An &quot;override&quot; keyword for
&gt; example, whose semantic would be &quot;the prose for this operation defines what the
&gt; inherited operation does when applied to objects implementing this interface,
&gt; overriding the superclass&apos; definition&quot;, with the requirement that the
&gt; signatures be identical or that the subclass&apos; signature be a subset (as here)?

I&apos;m confused.  Do you want HTMLPropertiesCollection.prototype.namedItem to exist or not?  If it should exist, how does its behaviour differ from HTMLCollection.prototype.namedItem called on the same object?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74319</commentid>
    <comment_count>6</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-09-23 01:09:06 +0000</bug_when>
    <thetext>heycam: I don&apos;t know, I just want to make bz happy...

I think I want HTMLPropertiesCollection.prototype.namedItem to exist (and its behaviour to be as specced today), but the question is what does HTMLCollection.prototype.namedItem do when called on an HTMLPropertiesCollection? Or in general, what does a method do when it is defined on an interface that is the superclass of another interface that redefines that method to do something else (overrides it), but the superclass method is then invoked on the subclass?

I&apos;d be pretty much fine with any behaviour except &quot;do what it is defined to do on the superclass&quot; since that would require having to work out every combination of method called on any subclass of its interface that overrides that method, which could be easy to screw up.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79320</commentid>
    <comment_count>7</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2012-12-03 21:43:55 +0000</bug_when>
    <thetext>My suggested solution is:

  * Have the definition of HTMLCollection.namedItem include a hook that
    other specifications can override for descendant classes like
    HTMLPropertiesCollection.

  * Do that overriding for HTMLPropertiesCollection.

  * Not define a distinct namedItem on HTMLPropertiesCollection.

I can see that if you did still include a namedItem on HTMLPropertiesCollection with its special behaviour, then you could save yourself effort by putting an extended attribute on HTMLCollection&apos;s one (which means &quot;delegate to the subclass&quot;) but I don&apos;t think it&apos;s really necessary for IDL support there, or for HTMLPropertiesCollection.namedItem to exist in the first place.

(If HTMLPropertiesCollection.namedItem did still exist, I would make it work only on HTMLPropertiesCollection objects, which would be the default behaviour anyway.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81030</commentid>
    <comment_count>8</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2013-01-08 07:05:24 +0000</bug_when>
    <thetext>I just took another look at this.

I actually don&apos;t see the problem with overriding namedItem like you do currently, and leaving the existing HTMLCollection.prototype.namedItem to work as it is described if you call HTMLCollection.prototype.namedItem.call(aPropertiesCollection, ...).  The behaviour seems to be defined well enough.  If you think this does not make sense, then I think HTMLPropertiesCollection should not be an HTMLCollection.

Either of these will be simpler than defining a hook to define the behaviour for HTMLCollection.namedItem.


If you do make HTMLPropertiesCollection not inherit from HTMLCollection, you could still have it be a &quot;collection&quot; in the sense of the term defined in the DOM spec.  That would save some redefinition.  The two members that you currently inherit -- item() and length -- are simple to define in prose given the current definitions of &quot;collection&quot; in the DOM spec.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81162</commentid>
    <comment_count>9</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-01-10 00:54:22 +0000</bug_when>
    <thetext>I guess if all the current combinations are well-defined, we can just be really careful not to introduce any ill-defined cases.

bz: Do you agree with heycam that your original report is actually wrong and namedItem(), when taken from HTMLCollection but applied to HTMLPropertiesCollection, is actually well-defined after all?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81167</commentid>
    <comment_count>10</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-01-10 01:26:42 +0000</bug_when>
    <thetext>I think that&apos;s fine, but then we should just change HTMLCollection to return &quot;Element?&quot; for its namedItem, I suspect.  At least if there are no other weird cases like this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84092</commentid>
    <comment_count>11</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-03-07 23:10:34 +0000</bug_when>
    <thetext>Ok. I&apos;ve changed the comments to say &quot;shadows&quot; instead of &quot;overrides&quot;, since you can still get the parent ones. I&apos;m reassigning this to Anne for the remaining DOM stuff.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84093</commentid>
    <comment_count>12</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-03-07 23:14:39 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r7739.
Check-in comment: Change comment to be more precise.
http://html5.org/tools/web-apps-tracker?from=7738&amp;to=7739</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84113</commentid>
    <comment_count>13</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2013-03-08 10:15:15 +0000</bug_when>
    <thetext>I&apos;m not sure what needs doing now. Should I change DOM&apos;s HTMLCollection &quot;object?&quot; to &quot;Element?&quot;? Is that it?

Should HTML&apos;s HTMLAllCollection then change &quot;object?&quot; to &quot;(Element or HTMLCollection)?&quot; maybe?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84905</commentid>
    <comment_count>14</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2013-03-25 04:53:10 +0000</bug_when>
    <thetext>(In reply to comment #13)
&gt; I&apos;m not sure what needs doing now. Should I change DOM&apos;s HTMLCollection
&gt; &quot;object?&quot; to &quot;Element?&quot;? Is that it?

If HTMLCollection.prototype.namedItem only ever returns an Element or null even when applied to an HTMLAllCollection, which is how I understand it, then make it return &quot;Element?&quot;.

&gt; Should HTML&apos;s HTMLAllCollection then change &quot;object?&quot; to &quot;(Element or
&gt; HTMLCollection)?&quot; maybe?

Yes, the latter is a bit more descriptive.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84931</commentid>
    <comment_count>15</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2013-03-25 17:16:49 +0000</bug_when>
    <thetext>https://github.com/whatwg/dom/commit/9ad090672d52b542818a528e2425eafa30c0721b

Reassigning to Ian to make HTML clearer as per comment 13 and comment 14.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86969</commentid>
    <comment_count>16</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-04-29 23:09:05 +0000</bug_when>
    <thetext>Thanks.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>