Update condition from elem.parentNode to elem

This would eventually return at the html level rather than the
document level, which seems like that not what is supposed to
be happening.