[whatwg] HTML 5 : Misconceptions Documented
giecrilj at stegny.2a.pl
Tue Aug 12 04:53:31 PDT 2008
It is probably too late for that but I like the concept of a default
property much better than metaattributes like IndexGetter.
For example, document.forms(0) means "call forms on document with argument
0". That is impossible because forms is not a function so we look into
forms collection and we see that it has the default method named item. So
we proceed by expanding it to document.forms.item(0) and we see it works.
I like it because it is simple, elegant and generic, whereas IndexGetter and
what you have looks ad-hoc.
I have never seen document.forms.main used to get at the form named "main"
but probably I have not seen that much. I wonder how common it is.
Of course, I agree that it is best to be explicit and not to rely on such
tricks at all. The downside is that, for example, while
a.getAttributeNode("href").value = url is technically superior to a.href =
url, it is much harder to read so care must be taken not to overshoot. But
form.elements.item("main") is just fine.
Regarding how the named elements get to be true properties, the shadowing
behavior can be specified without recurring to getters. It is sufficient to
say that an intrinsic property is never replaced by a constructed shortcut
property and we get the same result.
From: whatwg-bounces at lists.whatwg.org
[mailto:whatwg-bounces at lists.whatwg.org] On Behalf Of Garrett Smith
Sent: Wednesday, August 06, 2008 8:49 AM
To: Thomas Broyer
Cc: whatwg at whatwg.org
Subject: Re: [whatwg] HTML 5 : Misconceptions Documented
On Tue, Aug 5, 2008 at 4:02 PM, Thomas Broyer <t.broyer at gmail.com> wrote:
> On Tue, Aug 5, 2008 at 8:03 AM, Garrett Smith wrote:
>> On Mon, Aug 4, 2008 at 3:17 PM, Thomas Broyer wrote:
>> First off, the IndexGetter behavior on the HTMLCollection is the
>> authors imagination.
> Aren't "document.forms" and "document.forms.myform" working?
Can you be more specific and direct in your reply? It isn't clear what
your point is.
>> The following example shows that indexed Properties exist on
>> NamedNodeMap, HTMLCollection, NodeList (just like they do on Arrays).
>> There is no [[ IndexGetter ]] as Cameron likes to make pretend.
> This is an "implementation detail" of the ECMAScript binding.
In EcmaScript, the property access operators seem to look like a
"getter" to Cameron. What they really do is provide access to
properties added to the collection, or, in one case (on one
implementation), this seems implemented as a "getter". A "getter" is a
method that gets the value of a property of that name.
More information about the whatwg