Julian Hall

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromJulian Hall
ToMe
SubjectHowToCreate.co.uk - xor
Date5 March 2007 19:03
Just a quick query: have you considered "foo ? !bar : bar" as a way of
implementing logical xor, and if you have, why did you decide not to include
it on your page?
FromMe
ToJulian Hall
SubjectRe: HowToCreate.co.uk - xor
Date5 March 2007 19:29
Julian,

> Just a quick query: have you considered "foo ? !bar : bar" as a way of
> implementing logical xor, and if you have, why did you decide not to
> include it on your page?

Nice and neat, but it fails to address the problem of bar being an
expression that must be evaluated only once (the purpose for writing it in
the first place). Though I suppose it can be used inside a function, the
same as any of the other algorithms could. Thanks for pointing it out, I
will add a note about it.


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromJulian Hall
ToMe
SubjectIterating over nodes in DOM tree created with invalid HTML in IE6
Date10 May 2007 15:19
Slightly strange problem here; I've looked at your site and you don't seem
to have any advice on the issue, but it's thanks to your DOM tree displaying
script that I realised that IE is behaving completely inconsistently here,
so thought I'd let you know something strange is going on.  I'm using
Internet Explorer 6 on XP.

The basic problem occurs if you have a section of your DOM that was created
from HTML with overlapping tags. The particular case I'm looking at is text
copied & pasted from either [a PDF] or a broken web page into a
contentEditable 'div'.  The HTML that is copied looks something like this:

<P>Some text is here</P>
<P><STRONG>
<P>A header here</P></STRONG>
<P>Some more text</P>

The best way of seeing what happens is to drop it into a div and view it
using your DOM tree script.  It actually works pretty-much as expected. 
There's an empty <STRONG> element sitting out on the end of the second
paragraph, so if you just look at the tree you wouldn't expect "A header
here" to be displayed in bold (although it is), but otherwise it looks OK. 
The bizarre behaviour occurs if you change the script, to use the iteration
technique that I normally use.  Instead of :
           for( var x = 0; topElement.childNodes[x]; x++ ) {
               outStr += showDomTree( topElement.childNodes[x],
topCode+'_'+x );
           }

Try:
           for (var n = topElement.firstChild; n; n = n.nextSibling) {
               outStr += showDomTree( n, topCode+'_'+x )
           }

Now things appear in the wrong place and opening branches causes strange
stuff to happen.  Yet the code looks from the definition of the attributes
used like it should behave identically.

Don't know if you want to add a note to your site about this behaviour, it
could prevent somebody having the strange kinds of trouble I've been seeing
lately...
FromMe
ToJulian Hall
SubjectRe: Iterating over nodes in DOM tree created with invalid HTML in IE6
Date10 May 2007 17:45
Julian,

> Don't know if you want to add a note to your site about this behaviour, it
> could prevent somebody having the strange kinds of trouble I've been
> seeing lately...

You basically got caught by one of IE's cyclic tree branches.

Hixie already did a great job of documenting this - better than I could:
http://ln.hixie.ch/?start=1037910467&count=1
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.