Test isElement instead of isDef (thanks @fredj)