Why I hate the W3C

Reply

Join Date: Apr 2005
Posts: 1,415
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 227
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Why I hate the W3C

 
1
  #1
Jan 17th, 2008
So, I've got a nifty little recursive function that runs through a select box and all it's children looking for the selected element and removes it, if the parent element is empty then it removes that as well. However, the W3C decided when passing DOM that there are 12, count 'em, 12 different node types.

So my function works perfectly well until it tries to do it's job and crawls across an option node, which as defined by DOM has a nodeType of 3 (text node). However, the brilliant engineers decided that TEXT NODES should have child nodes which mirror the text attribute, ie.,
<option id="s3">Text is here</option>
DOM:
element.id    = "s3"
element.text = "Text is here"
element.childNodes = ["Text is here"]
     [0]
         nodeType = 3
         nodeValue = "Text is here"

This, of course, boggles my mind. So checking nodes for the number of child nodes results in a false positive on option type nodes causing the function to incorrectly call and put itself into an infinite loop crawling the same node.

I've fixed it by kludging the crap out of it when checking the nodeType as well as the node length but.. wow, how on earth is that even logical?
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the IT Professionals' Lounge Forum
Thread Tools Search this Thread



Tag cloud for IT Professionals' Lounge
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC