Title: Re: [WSG] Calling JS gurus

Chris
  You've hit the nail on the head with parsing, but development (coding lines), wise innerHTML is a useful hack as you say.  'Tis a pity that loadXML is at document level rather than executable at node.

----- Original Message -----
From: [email protected] <[email protected]>
To: [email protected] <[email protected]>
Sent: Tue Oct 03 22:15:23 2006
Subject: Re: [WSG] Calling JS gurus

> innerHTML is good because it's quite a bit faster than DOM methods; if
> you don't need to manipulate the output further, there's nothing wrong
> with using innerHTML (IMHO; XHTML-fanatics may not agree).
>
> As to the article, I don't really understand what you're trying to do
> - doesn't cloneNode() do all that and more?

I thought the same, but it doesn't. The plan is to turn something like:

<h1>boo<h1> into <h1><span>boo</span></h1> and cloneNode() works if
there is only one child node in there. In a case like
<h1><span>bla</span>boo</h1> it'll fail. You need to loop through all
childNodes and clone each of them.

That said, I'd probably use innerHTML there. You can manipulate it
anyways, as all you need to do is to loop through the childnodes
again.

innerHTML is lazy, but not evil. When it comes to heavy HTML
manipulation or pulling in content from other sources it is a time
saver. If you generate HTML from scratch within _javascript_, it is
cleaner to use the DOM methods, as you leave a crumbstrail of
variables behind.

--
Chris Heilmann
Book: http://www.beginningjavascript.com
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/


*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************


*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************

Reply via email to