Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.chainon-marquant.org!nntpfeed.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <1460484.mR14RZRZF0@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Mon, 31 Oct 2011 11:50:06 +0100 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 8Bit Subject: Re: Changing letters in boxes Newsgroups: comp.lang.javascript References: <1cb16076-87c8-4bc6-8007-1efddfb7530b@s10g2000yqa.googlegroups.com> <3024323.SPkdTlGXAF@PointedEars.de> <48b611a8-825b-49cf-bff1-e786e15f7361@f3g2000pri.googlegroups.com> Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 68 NNTP-Posting-Date: 31 Oct 2011 11:50:07 CET NNTP-Posting-Host: 87fe7955.newsspool2.arcor-online.net X-Trace: DXC=I37P\CfIFKdLPRgcbZZF88L1QRb X-Complaints-To: usenet-abuse@arcor.de Xref: x330-a1.tempe.blueboxinc.net comp.lang.javascript:7892 RobG wrote: > Thomas 'PointedEars' Lahn wrote: >> A safer approach is to remove all cells of the row except one, then >> replace the content of the first cell and add more cells: >> >> var tr = document.getElementById("box"); >> var firstChild = tr.firstChild; >> while (tr.lastChild != firstChild) >> { >> tr.removeNode(tr.lastChild); >> } >> >> tr.cells[0].innerHTML = a; > > You seem to be assuming here that the firstChild of the tr will be a > cell (TD or TH), when it may be a text node: ACK > […] > To get the first cell, better to be explicit: > > var firstCell = tr.cells[0]; ACK > An alternative is getElementsByTagName('td')[0], but the cells can be > TH or TD, using the cells collection deals with both. A viable alternative alternative are the `firstElementChild' and `lastElementCild' properties if they are available. > [...] >> When all you know is jQuery, every problem looks $olvable. > > is that one of yours? Yes :) It occurred to me when reading from John-David Dalton (@jdalton, on Twitter) that the jQuery Standards Group (sic!) he recently joined is going to suggest adding Array methods to NodeLists because they see so much [].forEach.call(hostObject) etc. these days. Of course, my answer was – the fact aside that this would make the DOM API language-dependent – that in a well-developed Web application you seldom ever need [].….call(hostObject) to begin with. > 1. http://msdn.microsoft.com/en-us/library/ms533897%28v=VS.85%29.aspx Thanks a lot, for some reason I had to rely on long-forgotten table- scripting experience with MSHTML and third-party information regarding this. It is acceptable to see this quirk being officially documented at last. In fact, when you read on to [1] they are saying in the "Creating and Manipulating Tables" section that the `innerHTML' and `innerText' properties are *read-only* for `table' and `tr' objects, which makes kind of Microsoftish sense considering the quirks and their proprietary table object model. This would mean it is not only unwise to use `innerHTML' there, but that it was functionally impossible. PointedEars ___________ [1] -- var bugRiddenCrashPronePieceOfJunk = ( navigator.userAgent.indexOf('MSIE 5') != -1 && navigator.userAgent.indexOf('Mac') != -1 ) // Plone, register_function.js:16