Compare 2 elements

Below is a typical way to check if the focus is on an element certain (txtCmd),

if(document.activeElement === txtCmd){
                return
}

I’m worried the operator=== would compare the entire element tree (every attribute and every sub-element) that would be low performance.

Does just compare the elements’ Ids is better?

document.activeElement.id === txtCmd.id

PS: There are no different elements with identical ID in the page.