Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!news.internetdienste.de!noris.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <1784154.EMZun36R47@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Mon, 31 Oct 2011 02:19:21 +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> Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 59 NNTP-Posting-Date: 31 Oct 2011 02:19:22 CET NNTP-Posting-Host: 7782107e.newsspool3.arcor-online.net X-Trace: DXC=`L<_QU_[o`\E47KDAk81NWMcF=Q^Z^V3X4Fo<]lROoRQ8kFIFKdLPRgS3?AEY=\RkWQ X-Complaints-To: usenet-abuse@arcor.de Xref: x330-a1.tempe.blueboxinc.net comp.lang.javascript:7889 Matt McDonald wrote: > Thomas 'PointedEars' Lahn wrote: >> Unreliable. Especially MSHTML (the layout engine that Internet Explorer >> uses) is prone to errors with `innerHTML' accesses in table structures. >> >> 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... > > Agreed. Given the Table API that the DOM provides, usage of innerHTML > here is erroneous, especially in IE. There's also, of course, > createElement + appendChild if desired. > > I wrote an article earlier today on this topic, except utilizing the DOM > Table API (insertCell + deleteCell): > > http://www.fortybelow.ca/hosted/comp-lang-javascript/table-cell- replacement/ > > Comments are welcome. One problem which what you dubbed "DOM Table Cell API" (there really is no official name for that part of the W3C DOM Level 2 HTML Specification) is that the W3C DOM API Specification and the MSHTML DOM API definition disagree (again, cf. HTMLSelectElement::add() [1]) with regard to the meaning of the method's arguments and its return value: Both support the value -1 to append a new cell; but while the standards- compliant implementation requires the number of existing cells to be passed for an alternative of that (tr.cells.length), MSHTML is at least documented to require tr.cells.length - 1. Also, while the standards-compliant implementation is supposed to throw DOMException INDEX_SIZE_ERR on error, MSHTML is at least documented to throw no exception at all then, but to return "null" instead (which, for the ECMAScript binding, is the `null' value of the JScript implementation of the Null type). [2] The same problem exists with HTMLTableElement/HTMLTableSectionElement::insertRow(). [3] Those differences suggest the possibility of other differences between standards-compliant and other implementations than the MSHTML DOM in this area. Therefore, I have intentionally used DOM Level 2+ Core methods in my example – for which I am not aware of such quirks – and made no mention of that "DOM Table Cell API". PointedEars ___________ [1] [2] [3] -- var bugRiddenCrashPronePieceOfJunk = ( navigator.userAgent.indexOf('MSIE 5') != -1 && navigator.userAgent.indexOf('Mac') != -1 ) // Plone, register_function.js:16