Should check if attribute exists in order to throw Error

When a DOM element does not have an id it returns an empty string instead of undefined