Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #17293
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.teledata-fn.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset="ISO-8859-1" |
| Message-ID | <19917857.WJ4dUYIvN4@PointedEars.de> (permalink) |
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Organization | PointedEars Software (PES) |
| Date | Sun, 18 Nov 2012 18:43:53 +0100 |
| User-Agent | KNode/4.4.11 |
| Content-Transfer-Encoding | 7Bit |
| X-Face | %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v |
| Face | iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== |
| Subject | Re: getElementsByClassName: BUG in JS-engine? |
| Newsgroups | comp.lang.javascript |
| References | <k8aee8$54m$1@dont-email.me> <50a8c202$0$6565$9b4e6d93@newsspool4.arcor-online.net> <50A8E917.3070303@geeeemeil.com> |
| Followup-To | comp.lang.javascript |
| MIME-Version | 1.0 |
| Lines | 64 |
| NNTP-Posting-Date | 18 Nov 2012 18:43:55 CET |
| NNTP-Posting-Host | 4d7cbe01.newsspool4.arcor-online.net |
| X-Trace | DXC=nlh7RgG1DEjFXUDVUnEXQm4IUK<Cl32<a4Fo<]lROoRa8kF<OcfhCOkEUNnbbFTL3bDZm8W4\YJNlJ`:FmdeL>K`nLCZKh];:6aKa;GWM;Jbbl |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | csiph.com comp.lang.javascript:17293 |
Followups directed to: comp.lang.javascript
Show key headers only | View raw
Mattias Campe wrote:
> Op 18-11-12 12:09, Martin Honnen schreef:
>> Most DOM collections are "live" collections so it is difficult iterating
>> over them while manipulating them. Your loop manipulates the class of
>> elements and that way the collection changes while the loop is executed
>> and that leads to elements being skipped as after setting
>> alleOpvallendeAlineas[0].className
>> that element is removed from the collection and the one that was at
>> index 1 is now at index 0. And the next loop iteration changes
>> alleOpvallendeAlineas[1]
>> which is the third element in the original collection.
>>
>> One way to avoid that problem is working from the end of the collection
>> e.g.
>> for (var l = alleOpvallendeAlineas.length, i = l - 1; i >= 0; i--) {
>> alleOpvallendeAlineas[i].className = ...;
>> }
>
> I wouldn't have found that explanation myself, but it all makes sense,
> once you know that :). So it's not a bug in the JS-engine after all ;).
It could not have been a bug in "*the* JS-engine" because
1. There is no such thing. Netscape/Mozilla JavaScript (e.g. in
Mozilla-based browsers, NES compatibles, B2G, and Firefox OS) is but one
of several ECMAScript implementations. Other major implementations
include JScript (e.g. in MSHTML/IE, with Windows Script Host, and on
IIS), V8 (e.g. in Chromium/Google Chrome, on Android, and as base of
node.js), Apple JavaScriptCore (e.g. in Safari, and on the iPhone/iPad),
Opera ECMAScript (in Opera and Opera Mobile), and KDE JavaScript (e.g.
in Konqueror):
<http://PointedEars.de/es-matrix> (to be updated)
Despite the historic name of the newsgroup, all of those implementations
are on-topic here and in similar newsgroups in other Usenet hierarchies.
2. The feature you are using here is not part of any ECMAScript
implementation to begin with, but of a language-independent DOM API.
You are merely using an implementation of that with ECMAScript
implementations:
<https://developer.mozilla.org/en/docs/DOM>
Scripting a DOM using an ECMAScript implementation is on-topic here as
well.
That said, next time you should be slow(er) to declare something a bug
without being sure, much less use the word "bug" that way in the message'
Subject:
<http://www.catb.org/~esr/faqs/smart-questions.html>,
in particular
<http://www.catb.org/~esr/faqs/smart-questions.html#idp29846432>.
HTH
PointedEars
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300dec7@news.demon.co.uk> (2004)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
getElementsByClassName: BUG in JS-engine? Mattias Campe <mattiaspuntcampe@geeeemeil.com> - 2012-11-18 11:47 +0100
Re: getElementsByClassName: BUG in JS-engine? Martin Honnen <mahotrash@yahoo.de> - 2012-11-18 12:09 +0100
Re: getElementsByClassName: BUG in JS-engine? Mattias Campe <mattiaspuntcampe@geeeemeil.com> - 2012-11-18 14:56 +0100
Re: getElementsByClassName: BUG in JS-engine? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-11-18 18:43 +0100
csiph-web