- From: Cameron McCormack <cam@mcc.id.au>
- Date: Wed, 13 Apr 2011 14:43:41 +1200
- To: Lachlan Hunt <lachlan.hunt@lachy.id.au>
- Cc: Boris Zbarsky <bzbarsky@MIT.EDU>, public-webapps <public-webapps@w3.org>
Lachlan Hunt: > I reviewed WebIDL again, and I think I've started to understand the > difference between sequence<T> and T[] now. > > As I understand it, the algorithm to convert an ECMAScript object to > an IDL sequence should work with any object that has a length > property and indexed values containing Node objects. That is true > for an Array of Nodes, NodeList, HTMLCollection and the above JQuery > case, they can all be handled in the same way. Yes, that’s right. > This seems to differ from the algorithm given for T[], which > requires that the object be either an array host object or a native > object, which would not handle the JQuery case. The sequence<T> > type seems more generic than that as the algorithm seems to be able > to support any object with a length and indexed properties. Why wouldn’t it handle the JQuery case? Isn’t it a native object? > I've updated and simplified the spec to handle the above case using > the parameter sequence<Node>. I still need to update the prose to > say that while the collections may contain any Node, only Element > nodes are added to the list of contextual reference elements. But > the following cases should all work. Agreed, that works, according to Web IDL’s currenty definition of overloading. The issue of whether you want to throw eagerly if passed an array with elements of the wrong type to an operation taking a sequence<T> is an interesting one, which probably still could bear some more discussion. On the one hand, it helps ensure implementations don’t diverge based on when during the course of running the method these elements from the sequence are looked up. I could mean a lot of useless checks, though. -- Cameron McCormack ≝ http://mcc.id.au/
Received on Wednesday, 13 April 2011 02:44:22 UTC