Path: csiph.com!news.swapon.de!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.datemas.de!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Recursive function to find a node in the DOM Date: Sun, 16 Aug 2015 08:48:58 +0200 Organization: PointedEars Software (PES) Lines: 44 Message-ID: <2800685.3l0yYTo2pD@PointedEars.de> References: <5530725.v0RXNFEj4j@PointedEars.de> <1885256.KGaLaWtVka@PointedEars.de> <4738754.gQ6MLv009L@PointedEars.de> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1439707946 10007 eJwFwQEBwCAMAzBLrNDukwM79S+BhFOhziVq0XScBrJwPQezdxTlEqrOHmmd7boE1BjW/z0TNhDg (16 Aug 2015 06:52:26 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sun, 16 Aug 2015 06:52:26 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwNy8EBwCAIA8CViiRRxgEp+4/Q3v/oMt0NUeBwuuoMK82Ze8IsnvQeREyDF/JnI6lmKeDod2HuWup/7hMfXtoVoQ== Cancel-Lock: sha1:16QQA3J7AS18n0ncrLgwxdmOERg= X-NNTP-Posting-Host: eJwFwYEBADAEA7CbjBbn2PD/CUugFD43gobFWt8YPgZjvaymyiRzFHRKaPUBVdZvR2SfDyCGEPA= Mail-Copies-To: usenet@PointedEars.de Xref: csiph.com comp.lang.javascript:28533 Christoph M. Becker wrote: > On 12.08.2015 at 01:18, Thomas 'PointedEars' Lahn wrote: >> Christoph M. Becker wrote: >>> On 08.08.2015 at 09:33, Thomas 'PointedEars' Lahn wrote: >>>> […] you can do an iterative "user-land" walk of the document tree as >>>> well; for example: […] >>>> >>> How can this be done with an iterative algorithm? >> You are the reader, you figure it out :-p > > Well, you have claimed "you can do an iterative "user-land" walk of the > document tree", so you may care to explain how. :) I thought my illustration above in combination with what I said about the property values under certaining conditions was, well, illustrative. Perhaps you want to use a fixed-width font. Simply handing out the algorithm would defeat the purpose of the exercise. > I claim that […]. I am not able to prove that, however. We can safely ignore it then. > FWIW, I might do something like the following: > > function eachChildOf(node, func) { ^^^^^^^^^^^ > node = node.firstChild; > while (node) { > func(node); > eachChildOf(node, func); ^^^^^^^^^^^^^^^^^^^^^^^^ > node = node.nextSibling; > } > } But that is recursion, and, as I indicated, you can do this without recursion. Try again. -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.