deregister element when detaching. Added more jsdoc