Re: Array-with-item in WebIDL

On 6/17/15, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 6/17/15 2:11 AM, Garrett Smith wrote:
>> https://developer.mozilla.org/en-US/docs/Web/API/Node/contains
>
> Ah, from Node, fine.  But no one is proposing replacing HTMLFormElement
> by an Array subclass, so this is not an issue.
>
>>>>    HTMLSelectElement
>
> Again, no one is suggesting replacing that by an Array subclass.
>
>> SELECT and FORM elements have a contains method. And they are
>> arraylike in that they have a length and indexed properties.
>
> OK, but see above.  So not relevant to this discussion.
>
>> I don't understand that documentation.
>
> Then maybe you shouldn't claim things aren't non-standard if you don't
> understand the standard?
>

With an attitude like that, how likely are web programmers to read it
and give feedback on it?

> The point is, per spec HTMLObjectElement instances are callable.

That's a sub sub point to the bigger point. And if that subpoint is
corret, then the spec/draft should say that. Does it? No, looks like
it says that OBJECTs have a legacycaller property whose name or type
is `any`.

The bigger point is "What's arraylike and has a contains method on the
web"? The main point is about adding item and contains to Array (and
that arises because of the decision to favor interface objects over
IBD, the discussion for the latter was lost about 9 years ago).

And
> HTMLCollection has a named getter.  So <object id="contains"> will show
> up in the HTMLCollection as a property named "contains" (because of the
> named getter) and the value will be a callable HTMLObjectElement instance.
>
> None of which is relevant to the discussion at hand, because no one is
> suggesting replacing HTMLCollection with an Array subclass.
>

I read: "We tried to add contains to Array.prototype for ES7 but it turns out
to break the web."

Ducktyping and feature testing is relevant in JavaScript. Feature
tests for contains might be along the lines of:—

if(typeof x.contains == "function") {

}

The list was correct & relevant. Mootools also adds a `contains` method.

You should test first before posting.

The HTML5 spec saying OBJECT *has* a `legacycaller` property is
confusing. It doesn't clearly say that the OBJECT element *is*
callable. Most web developers don't read specs because the specs are
confusing. You have an arrogant attitude about bad documentation for
bad API design and I don't like it.
-- 
Garrett
@xkit
ChordCycles.wordpress.com
garretts.github.io
personx.tumblr.com

Received on Wednesday, 17 June 2015 14:49:08 UTC