Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #14418
| Message-ID | <1597054.oMNUckLgyt@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2012-06-09 11:43 +0200 |
| Subject | Re: Changing styles values by Element Name |
| Newsgroups | comp.lang.javascript |
| References | (2 earlier) <XnsA067B487E79B6eejj99@194.109.133.133> <jqg30i$kvt$1@dont-email.me> <jqlq19$3lp$1@dont-email.me> <jqmk7a$l2j$1@dont-email.me> <XnsA06A79B8BBB29eejj99@194.109.133.133> |
| Followup-To | comp.lang.javascript |
Followups directed to: comp.lang.javascript
Evertjan. wrote:
> Scott Johnson wrote on 06 jun 2012 in comp.lang.javascript:
>> On 6/5/2012 1:26 PM, Jeremy J Starcher wrote:
>>> On Sun, 03 Jun 2012 09:22:18 -0700, Scott Johnson wrote:
>>>> On 6/3/2012 8:44 AM, Evertjan. wrote:
>>>>> Martin Honnen wrote on 03 jun 2012 in comp.lang.javascript:
>>>> Ahhh now I see.
>>>>
>>>> getElementsByName returns an array of (duh) elements. I guess the (s)
>>>> should of clued me in.
>>>
>>> Actually, it returns at HTMLCollection which is array-like. The
>>> difference may seem subtle, but confusing the two can cause bugs or
>>> runtime errors.
>>>
>>> https://developer.mozilla.org/en/DOM/HTMLCollection
>>
>> Thanks for the extra info and link. Valuable info.
>
> All js-variables are valuable, even with "undefined".
You misunderstand. Scott thanked Jeremy for the information he provided to
him – that getElementsByName() only returns a (reference to) an array-*like*
object which implements the HTMLCollection interface. He considered that
information valuable.
However actually, the method is *specified* to return a reference to an
object implementing the *NodeList* interface instead:
[1] <http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-71555259>
[2] <http://www.whatwg.org/specs/web-apps/current-
work/multipage/dom.html#dom-document-getelementsbyname>
It is a specialty of the Gecko DOM that the referred object also implements
the HTMLCollection interface:
<https://developer.mozilla.org/en/DOM/document.getElementsByName>
(refers to both the specifications above)
This can be proven by showing that in Iceweasel (Firefox) 10.0.5 the
referred object inherits a namedItem() method, which is native to
HTMLCollection and HTMLOptionsCollection implementations only [1].
I do not understand to what end that is in the Gecko DOM, as the namedItem()
method of the referred object, when called with the name as argument can
reasonably at most only return the same value that the item() method returns
when called with argument 0 (to yield the first item of the NodeList) [1].
> All[?] DOM collections can be actively used in JS,
No, it depends on the runtime environment of the ECMAScript implementation
that provides the DOM implementation whether and which DOM collections can
be used.
> except the garbage collection.
You are not making sense. Garbage collection is a functionality of the
ECMAScript implementation; it is not a DOM collection.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Changing styles values by Element Name Scott Johnson <noonehome@chalupasworld.com> - 2012-06-03 06:46 -0700
Re: Changing styles values by Element Name Martin Honnen <mahotrash@yahoo.de> - 2012-06-03 15:53 +0200
Re: Changing styles values by Element Name "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-06-03 15:44 +0000
Re: Changing styles values by Element Name Scott Johnson <noonehome@chalupasworld.com> - 2012-06-03 09:06 -0700
Re: Changing styles values by Element Name Scott Johnson <noonehome@chalupasworld.com> - 2012-06-03 09:22 -0700
Re: Changing styles values by Element Name Jeremy J Starcher <r3jjs@yahoo.com> - 2012-06-05 20:26 +0000
Re: Changing styles values by Element Name Scott Johnson <noonehome@chalupasworld.com> - 2012-06-05 20:52 -0700
Re: Changing styles values by Element Name "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-06-06 09:57 +0000
Re: Changing styles values by Element Name Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-09 11:43 +0200
Re: Changing styles values by Element Name Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-09 13:03 +0200
Re: Changing styles values by Element Name "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-06-09 14:14 +0000
Re: Changing styles values by Element Name Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-09 18:13 +0200
Re: Changing styles values by Element Name Luuk <luuk@invalid.lan> - 2012-06-09 18:35 +0200
Re: Changing styles values by Element Name "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-06-10 10:33 +0000
Re: Changing styles values by Element Name Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-10 14:50 +0200
Re: Changing styles values by Element Name SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-06-04 15:32 +0200
csiph-web