Reputation: 428
<!DOCTYPE html>
<html>
<body>
<div id='something'>
A text node.
</div>
</body>
</html>
var parent = document.getElementById('something');
var child = parent.childNodes[0];
alert(parent.contains(child));
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
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