Home Dashboard Directory Help
Search

Node.parentElement incorrectly returns null. by Pete Blois


Status: 

Closed
 as Not Reproducible Help for as Not Reproducible


Type: Bug
ID: 786279
Opened: 5/3/2013 10:40:13 AM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description


According to the W3 spec (Working Draft)-
https://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-parentelement

Node.parentElement should return the element if the parentNode is of type element.

In IE, it appears to always return null for Nodes (it works for Elements).
Details
Sign in to post a comment.
Posted by Pete Blois on 6/27/2013 at 10:49 AM
I really think you're misreading the bug description and repro code- this bug applies to TextNodes NOT elements.

Testing again on IE11 beta, and node.parentElement is undefined for text nodes.

Everything works fine when the child is an element. It's wrong when the child is a text node.
Posted by Microsoft on 6/12/2013 at 8:33 AM
Thank you for your feedback.

In most cases, parentelement is the same as parentNode. The only difference comes when a node's parentNode is not an element. If so, parentElement is null.
Please provide a working example if you believe that IE10 is still showing null when it should not.

We value your feedback. If you have additional information that can help us recreate this issue — such as a specific url, more detailed steps, test results from different machines, or additional conditions — please reactivate the bug or submit a new bug with more details on how to reproduce the issue. You can also read the guidelines at https://connect.microsoft.com/IE/content/content.aspx?ContentID=16254 regarding filing a good bug report.

Best regards,

The Internet Explorer Team
Posted by Pete Blois on 5/28/2013 at 11:48 AM
Repro code:
var node = document.createTextNode('foo');
document.body.appendChild(node);
window.alert(node.parentElement == document.body);

node.parentElement is null, but node.parentNode is correct. As I mentioned above, this works correctly for elements, but not for nodes.
Posted by Microsoft on 5/6/2013 at 10:06 AM
Thank you for your feedback.

In most cases, parentelement is the same as parentNode. The only difference comes when a node's parentNode is not an element. If so, parentElement is null.
Please provide a working example if you believe that IE10 is still showing null when it should not.

We value your feedback. If you have additional information that can help us recreate this issue — such as a specific url, more detailed steps, test results from different machines, or additional conditions — please reactivate the bug or submit a new bug with more details on how to reproduce the issue. You can also read the guidelines at https://connect.microsoft.com/IE/content/content.aspx?ContentID=16254 regarding filing a good bug report.

Best regards,

The Internet Explorer Team
Sign in to post a workaround.