there was a longer discussion about this panic on the tdom mailing list. The maintainer seems still to believe that the panic is right behavior:
http://tech.groups.yahoo.com/group/tdom/message/1895
i have provided a real-life example with invalid "user input"
http://tech.groups.yahoo.com/group/tdom/message/1921
Andrew, maybe, it helps if you post your message & fix on the tdom mailing list....