This topic has been on my mind quite a bit lately as we’ve been working on a system to automatically publish information on the calls we (the North Karelia Rescue Department) get. I was originally planning on writing in Finnish about it, but the story (via) on Seattle Post-Intelligencer on how the Seattle FD changed its feed to prevent Seattle911.com from automatically displaying call locations on a map spurred me to write about in English first.
The OO programmer in me cringes. I ran into a bug last week in my DOM traversion code that was a bit tricky to solve. The hardest part was isolating the problem since the code had worked before some logic changes needed to be done. Once the problem was isolated I noticed that I kept getting a Text-node that wasn’t an instance of the DOM class
Text (which inherits from
CharacterData which in respect inherits from
Node) but something else (with a class of
Without going into details of why I wasn’t getting a Text-node (I confess, I didn’t have the time to figure it out, just come up with a solution), I decided to solve the issue by inspecting the class of the node that I got. If the class was empty or
Text I’d just skip it and go to the current elements parent, otherwise I’d just get the previous sibling with
previousSibling. Of course the code for this is simply:
if ((node == null) || (node instanceof Text))
// Do something
This worked fine in Firefox. Time to test in IE. And what do we find? IE doesn’t recognize a class
Text (or any DOM class). Searching for a solution on the Google didn’t provide any sensible answers other than the information that IE doesn’t create DOM classes are real classes but something else. So with IE you can’t try to use the simplest method to figure out the class of a node (for example in a
NodeList returned by
The OO purist in me is screaming and crying. Such elegant simplicity taken away from me by IE’s stupidity. Aargh!
P.S. Don’t ask me how I solved it. The current fix is a hack that needs to be tested better before I’ll trust it.
One of the reasons randomfire’s been so silent during the summer and early fall has been my attempt to massage WordPress so that the Picture-a-Day part would behave like I want it to. I finally gave up and moved my photoblog portion over to Pixelpost and am now publishing it as randomfire: shutterclicks.
Now I just need to get back to massaging the new theme to work as I want it to in every other respect. But I really should write more too…