hype-vhs
hype-vhs

Reputation: 428

IE acting strange with Node.contains and Text nodes

Document

<!DOCTYPE html>
<html>
    <body>
        <div id='something'>
            A text node.
        </div>
    </body>
</html>

Script

var parent = document.getElementById('something');
var child = parent.childNodes[0];
alert(parent.contains(child));

Results

I would expect a Node to contain its own childNode. However, in IE 11, if that child is a Text node, this is apparently not the case.

IE has odd behavior with Node.contains and Text nodes. What is the justification, and why does it occur?

Upvotes: 3

Views: 839

Answers (1)

user1106925
user1106925

Reputation:

"What is the justification, and why does it occur?"

Browsers are very complex and bugs occur in every browser.

Furthermore, I'm pretty sure that IE invented the .contains() method. If so, it would really only be a bug in the sense that the later standardization of the method didn't follow their implementation.

Upvotes: 1

Related Questions