getElementsByClassName

D

Dr J R Stockton

In comp.lang.javascript message <[email protected]>,
Mon, 11 Jul 2011 11:32:12, Thomas 'PointedEars' Lahn
Dr said:
Thomas 'PointedEars' Lahn posted:

Undoubtedly confusion exists.

True, thanks for pointing this out. I meant to say:

A for-in loop iterates only through the properties that are enumerable,
i. e. those that do _not_ have the `[[DontEnum]]' attribute in conforming
implementations of ES3, and those that _do_ have the `[[Enumerable]]'
attribute in conforming implementations of ES5 (cf. sections 8.6.1,
respectively).

Readers might also be interested in Object.getOwnPropertyNames(element)
which is used in <http://www.merlyn.demon.co.uk/js-probs.htm> though the
actual code is in <http://www.merlyn.demon.co.uk/inc-props.js>. But,
last time I checked, only 2 of my 5 browsers had it.

Not now in IE 8 FF 3.6 Op 11.50.
In, but not new, in Sf 5.0.5, Cr 12.0.
The FF5 machine is not currently running.
 
A

Aaron Gray

Dr J R Stockton said:
In comp.lang.javascript message <[email protected]>,
Mon, 11 Jul 2011 11:32:12, Thomas 'PointedEars' Lahn
Dr said:
Thomas 'PointedEars' Lahn posted:
This will iterate through all properties of your collection.
No, only the enumerable ones, i. e. those with the `DontEnum' attribute
in conforming implementations of ES3, and those that do _not_ have the
`Enumerable' attribute in conforming implementations of ES5.

Undoubtedly confusion exists.

True, thanks for pointing this out. I meant to say:

A for-in loop iterates only through the properties that are enumerable,
i. e. those that do _not_ have the `[[DontEnum]]' attribute in conforming
implementations of ES3, and those that _do_ have the `[[Enumerable]]'
attribute in conforming implementations of ES5 (cf. sections 8.6.1,
respectively).

Readers might also be interested in Object.getOwnPropertyNames(element)
which is used in <http://www.merlyn.demon.co.uk/js-probs.htm> though the
actual code is in <http://www.merlyn.demon.co.uk/inc-props.js>. But,
last time I checked, only 2 of my 5 browsers had it.

Dr. Stockton, these URL's don't seem accessable they are giving 404's.

Aaron
 
D

Dr J R Stockton

Wed said:
Dr. Stockton, these URL's don't seem accessable they are giving 404's.

Sometimes I just do not type exactly what I ought to. Apologies. I've
actually copy'n'pasted these to a browser to test them :-
<http://www.merlyn.demon.co.uk/js-props.htm>
<http://www.merlyn.demon.co.uk/inc-prop.js>

So I am adding links to my include files in the JavaScript section of
<http://www.merlyn.demon.co.uk/index.htm>.

That page has, at the foot, a self-generated alphabetical current list
of all the URLs that it links to, which can be read if desperate.
 
T

Thomas 'PointedEars' Lahn

Gregor said:
Am 2011-07-10 08:27, Thomas 'PointedEars' Lahn meinte:
Gregor said:
Am 2011-07-09 21:50, Thomas 'PointedEars' Lahn meinte:
Gregor Kofler wrote:
Am 2011-07-09 17:44, Aaron Gray meinte:
for (e in elements) {
This will iterate through all properties of your collection.
No, only the enumerable ones, […]
For example the length property. Or the item property.
Which should not be enumerable in a reasonable (DOM) implementation.
var c = document.getElementsByTagName("p"), n;
for(n in c) {
console.log(n);
}

// Firefox 5 result: 0, 1, 2, 3, 4, 5, 6, length, item, namedItem
// Chromium 12 result: 0, 1, 2, 3, 4, 5, 6, length, item

Not only is item and length enumerable, but depending on the DOM
additional properties might pop up.
I think you know what to do now.

Get some sleep? Check. (Got some, unfortunately not enough.)

Point out, that properties inherited through the prototype chain will be
enumerated by a for ... in loop even if propertyIsEnumerable() returns
false? Check.

Close. What I meant is that someone[tm] should submit one or two bug
reports and/or patches to get this fixed.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,075
Messages
2,570,562
Members
47,197
Latest member
NDTShavonn

Latest Threads

Top