Comparing a DOM Node wih a DOM Element

dom, javascript

Solution

Just do an `===` comparison. Since they're both objects, the comparison will be identity based.

if (my_node === my_element) {
    // they're the same thing
}

Problem

I'm having some trouble figuring this problem out. I'm aware that everything in a DOM is a node and that a DOM element is also a node. However, my problem is this: I have a DOM node and a DOM element and I need to compare these to see if they are referring to the same element. Is that even possible? I think there is something fundamentally wrong with my question but can't figure out what it is. Thanks for your help.

Original source