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
Using [hasAttribute()](http://quirksmode.org/dom/core/#t125), not available in IE7 and below.