Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!xlned.com!feeder1.xlned.com!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="ISO-8859-1" Message-ID: <2931754.sreIk3pbUD@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Fri, 05 Oct 2012 01:02:01 +0200 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 7Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 58 NNTP-Posting-Date: 05 Oct 2012 01:02:01 CEST NNTP-Posting-Host: 398c025b.newsspool1.arcor-online.net X-Trace: DXC=OjMeB32E0LlHXPKDZm8W4\YJNLR=i2=[N6Y6JI8d2_XC2HW@k0D5aVUC[YM X-Complaints-To: usenet-abuse@arcor.de Xref: csiph.com comp.lang.javascript:16406 Andrew Poulos wrote: > If the server can return "arbitrary" but valid HTML such as > > "
" + > "
" + > "
" + > "
" + > "

style='font-size:14pt;color:#000000;font-weight:bold;'>The > Emergence

" + > "

style='color:#000000;'>The effect of globalisation and, more. >

" + > "

style='color:#000000;'> 

" + > "

style='color:#000000;'>I propose to consider

" + > "

style='color:#000000;'>

" + > "
" + > "
src='images/020808_1633_0030_lsls.jpg' alt='extreme' title='' > style='position:absolute; left:0px; top:0px; width:100%; height:100%; > margin:0;'>
" > > how can you possibly parse it and use createElement/appendChild to > recreate the HTML. Currently I'm using innerHTML. You can parse this efficiently using a regular expression containing token patterns matching grammar atoms in alternation and RegExp.prototype.exec(), then apply createElement/appendChild on the result. Unless you use setAttribute(), certain attributes must be handled specially because of their non-identifier name. The `style' attribute must be handled as a special case, i.e. you need to parse the attribute value to set style properties; either with the bracket property accessor syntax and a mapper for non-identifier style property names, or with CSSStyleDeclaration::setProperty(). ISTM you should prefer the `innerHTML' branch if that property is available and applicable to your use-case; it may be still proprietary but it merely encapsulates what browsers do best (within their limits): parse HTML so that the result can be rendered. But why does the server return HTML in the first place? PointedEars -- Sometimes, what you learn is wrong. If those wrong ideas are close to the root of the knowledge tree you build on a particular subject, pruning the bad branches can sometimes cause the whole tree to collapse. -- Mike Duffy in cljs,