This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
HTMLCollection has a namedItem method that returns "Element", and the interfaces that inherit from HTMLCollection (such as HTMLAllCollection) override it with a namedItem method that returns "object". This is a problem because you can't generate interfaces for any statically typed language (e.g. Java or Objective-C) from the WebIDL as written. The base class would return a specific type ("Element) but subclasses would return a more general type (Java "Object" or Objective-C "id"), which is not allowed in those languages. Return types in derived classes have to be covariant, not contravariant. This would be fixed by having namedItem() in the base interface declared to return "object" type, even though in practice a vanilla HTMLCollection will only return Elements.
As a side note, though contravariant return types are not really a problem in JS, declaring a more specific return type in the WebIDL doesn't particularly help JavaScript either. The exposed JavaScript behavior is not affected.
EDITOR'S RESPONSE: This is an Editor'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: Concurred with reporter's comments. But note that anyone who is using polymorphism with HTMLCollection is going to shoot themselves in the foot really badly.
Checked in as WHATWG revision r4418. Check-in comment: Change the IDL for HTMLCollection to support statically typed languages. http://html5.org/tools/web-apps-tracker?from=4417&to=4418
(In reply to comment #2) > > But note that anyone who is using polymorphism with HTMLCollection is going to > shoot themselves in the foot really badly. > I think you are probably right. All that's essential to be able to run the IDL compiler on the spec IDL to generate ObjC or Java bindings without failing.