Path: csiph.com!weretis.net!feeder4.news.weretis.net!news.mb-net.net!open-news-network.org!.POSTED.100.225.197.178.dynamic.wless.zhbmb00p-cgnat.res.cust.swisscom.ch!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Inserting a DIV inside another DIV Date: Sun, 27 Aug 2017 16:15:34 +0200 Organization: PointedEars Software (PES) Lines: 108 Message-ID: <7368313.T7Z3S40VBb@PointedEars.de> References: <6711ac96-c627-4e0c-b267-6a7602e0cdc5@googlegroups.com> <5095798.DvuYhMxLoT@PointedEars.de> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit Injection-Info: gwaiyur.mb-net.net; posting-host="100.225.197.178.dynamic.wless.zhbmb00p-cgnat.res.cust.swisscom.ch:178.197.225.100"; logging-data="6698"; mail-complaints-to="abuse@open-news-network.org" User-Agent: KNode/4.14.2 X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. On 27/08/17 02:16, Thomas 'PointedEars' Lahn wrote: >> Peter Flynn wrote: >>> Doubly confusing because the designer who chose that phrase also didn't >>> understand this kind of markup — you are correct, one does not "append" >>> inside an element, one "inserts". One "appends" to a list; if there is >>> nothing to append to, it makes no sense to use the word "append". > [snip] >> >> Utter nonsense. > > I'm afraid not. You are wrong. >> By calling the appendChild() method of an element object, one appends a >> child node to the list of child nodes of an element node, > > Right, no disagreement there. But what if there are no child nodes? Then the list of child nodes is *empty*, and the referred object’s `length` property has the value `0` (zero). Borrowing from mathematics (cf. “empty set”), in (theoretical) computer science the concept of emptiness acquires another and even a different, counter-intuitive meaning. For example, according to the theory of formal languages, every character of the text that you just read (including whitespace) has before and after it the “empty word” (commonly denoted ε [epsilon]), each of which produces an “empty string” (a string [of characters] of length zero, and indeed a String object with a `length` property value of `0`) as *match* when the ECMAScript regular expression (and in this case, also PCRE) `(?:)` is matched against the text as a String value: text.match(/(?:)/g) For another example (as you should know if you knew what you claimed you know), the *content* model of certain elements of certain markup languages is *empty* (SGML/XML: `EMPTY`). Colloquially this is a contradiction in terms, but it makes perfect sense in computer science because those languages *are* formal languages. > My point is that the choice of *name* for the method is misleading in > that circumstance. No, it is not. The node is *always* appended to, i.e. it is inserted *at the end* of, the list of child nodes. In computer science, inserting an element at the end of an empty list means to modify that list so that afterwards it contains only the inserted element(s), in insertion order. Moreover, if you append a node as child node to an element that already is a child node of the same element, it is moved towards the end of the list of child nodes (i.e. to the end of the target element). If it is already the child node of another element, it is moved from that element to the end of the target element. This is an easy and efficient way to rearrange child elements, for example for sorting a table [the recommendation is to sort the list as an Array first, then append each child element to the node list in array element order: [].slice.call(tBody.rows).sort((row1, row2) => …) .forEach((row) => tBody.appendChild(row)); ]. > "Insert" is the normal name for this action (see the > menus of any XML editor). No, an insertion into a list can happen at *any* position of the list (cf. “insertion sort”). Appending something is a *special* kind of insertion *at the end* (from Latin «appendēre» “to hang up”, “to suspend”, “to pay out”; cf. “appendix” etc.) That is why el.insertBefore(child, el.lastChild); is equivalent to el.appendChild(child); [If the element node has no child nodes, el.lastChild is `null`, and el.insertBefore() is specified and implemented to handle that, so this is safe in all cases.] > > Sadly, you have not the slightest clue what you are talking about. > > Oh dear. Q.E.D. >> To begin with, there is no “Javascript” (see sig). > > *plonk* LOL. So you have not read my sig and are out of arguments already? -- PointedEars FAQ: | | Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.