Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #26806

Re: Question about appendChild using series of divs

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Question about appendChild using series of divs
Date Thu, 05 Feb 2015 19:21:20 +0100
Organization PointedEars Software (PES)
Lines 100
Message-ID <1660995.P2mppIif9Y@PointedEars.de> (permalink)
References <mar78t$fq8$1@panix3.panix.com> <20656658.1E4ZlvUoOU@PointedEars.de> <mb0b1q$qv8$1@reader1.panix.com>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Trace solani.org 1423160525 1832 eJwFwYEBwDAEBMCVKN5nHBr2HyF3YVD86Qh4bGweGw+hKmVEvgLF0O19lZWSCuwwq3n9jD36GhBC (5 Feb 2015 18:22:05 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Thu, 5 Feb 2015 18:22:05 +0000 (UTC)
User-Agent KNode/4.14.2
X-User-ID eJwVyMkRwDAIBLCazJrFlMPZfwmZ6CkFD8sulVdX1wcHQkq2yGFCzF9UqfuGIFjPrGGGf1dfa2IixWYQ7R87UxWi
Cancel-Lock sha1:VioOBQG1p/ky3L1HC78YO2CEZ90=
X-NNTP-Posting-Host eJwFwQkBwCAMA0BL/RKGHEhX/xK4Q9KpVQQLg9HfHd+WzkqzPVVqS4XRVe4IXaAoHt0B8AAkwhEd
Xref csiph.com comp.lang.javascript:26806

Show key headers only | View raw


Gordon wrote:
^^^^^^
Again, this is Usenet; please use your full (real) name.

> Thomas 'PointedEars' Lahn <cljs@PointedEars.de>:
>> Gordon wrote:
>> > […]  In all five cases I use appendChild to attach the div
>> > to the 'H' div.  The divs then display in the same order.
>> > (I would think they would display in reverse order,
>> 
>> Unfounded.
>> 
>> > since they are being successively appended to 'H', not
>> > to the last appended, but they don't.)
>> 
>> “Append” means “to insert at the end” (cf. “prepend”).
> 
> It depends on what 'append' means in this particular
> context.

Yes.  But I think “to append a *child* (node)” is without ambiguity.

> If we consider H as a node in a graph
> ...-H-... and appending A to H results in ...-H-A-...,
> one might think subsequently appending B to H might
> be expected to result in ...-H-B-A-..., B being placed
> directly after H.  But obviously other interpretations
> are possible.  (Here I am conflating assumptions
> about the way the append takes place and the way
> the result is subsequently displayed.)

You need to consider this not as a linear graph, but a document *tree* of 
nodes:

  H
  :-- A
  :-- B
  :-- C
  '-- D

Hence append*Child*.

>> > While the page is up, if the user clicks on a link within
>> > one of the five divs, say 'C', another set of divs is similarly
>> > created, let us say 'c1', 'c2', 'c3', ....  These I append
>> > to div 'C'.  I want them to appear below 'C' and before 'D',
>> > but instead they display below 'E'.
>> 
>> You must have appended them to 'H' instead.
> 
> So you seem to agree with my assumption above, that
> the layout procedure reads the tree such that if I have appended
> c1 to C, then I ought to observe the divs in the
> order H, A, B, C, c1, c2, ..., cn, D, .... 

No, if properly done, the elements are *nested* thus:

  H
  :-- A
  :-- B
  :-- C
  :   :-- c1
  :   :-- c2
  :   :-- ...
  :   '-- cn
  '-- D

But apparently you did:

  H
  :-- A
  :-- B
  :-- C
  :-- D
  :-- c1
  :-- c2
  :-- ...
  '-- cn

That is, if the order is not as you expected, either you appended the 
elements to the wrong parent node, or a stylesheet (which can change the 
positioning of elements in the viewport regardless of source code/node 
order) interferes.

> (For space
> reasons the content of the divs will appear vertically,
> and inserted material should push the material after it
> in the tree downward.  Hopefully.)
> 
> Historically, the makers of browsers and script
> interpreters do not seem to have felt any obligation
> to do things in any particular way, […]

You are mistaken.  Ex falso quodlibet.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Question about appendChild using series of divs gcf@panix.com (Gordon) - 2015-02-03 14:24 -0500
  Re: Question about appendChild using series of divs JJ <jj4public@vfemail.net> - 2015-02-04 07:10 +0700
    Re: Question about appendChild using series of divs gcf@panix.com (Gordon) - 2015-02-05 18:02 +0000
  Re: Question about appendChild using series of divs Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-04 14:23 +0100
    Re: Question about appendChild using series of divs Tim Streater <timstreater@greenbee.net> - 2015-02-04 13:34 +0000
      Re: Question about appendChild using series of divs Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-04 15:12 +0100
    Re: Question about appendChild using series of divs gcf@panix.com (Gordon) - 2015-02-05 17:59 +0000
      Re: Question about appendChild using series of divs Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-05 19:21 +0100
        Re: Question about appendChild using series of divs John Harris <niam@jghnorth.org.uk.invalid> - 2015-02-05 19:36 +0000
          Re: Question about appendChild using series of divs Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-07 12:07 +0100
            Re: Question about appendChild using series of divs John Harris <niam@jghnorth.org.uk.invalid> - 2015-02-07 15:20 +0000

csiph-web