I didn’t want to have to tell you this way, but there’s just no way around it: in Internet Explorer 7 (I’ve left testing 6 and 8 as an exercise for the reader 🙂 ) the parentNode property can flat out lie to you – specifically – with pasted content in a rich text editor like TinyMCE. That’s right, a bold-faced chain-yanking tall-tale’d lie, and I’ll prove it to you.
According to the W3C documentation, “the parentNode property returns the parent node of a node.” And based on that, you would expect the following code to alert “true!” for as many times as the node has children:
As far as parentNode is concerned, if:
- you're writing a plugin for TinyMCE or similar
- you're dealing with (possibly) pasted content
- relying on parentNode
- validate! If(myNode != myNode.childNodes[i].parentNode) is true then you have a problem!
I hope you enjoyed the latest the-undocumented-life-of post! Also a fun read: The undocumented life of jQuery's .append()!
[viewcode] src=/tinymce/dom.txt name=dom lang=html[/viewcode]