Hm. If I am reading this correctly, when ``a === null`` an exception will be thrown ("Attribute defined too often."). I would suggest the correct way to do this check is:
``
if (!a && !element.hasAttributeNS(...)) {
    // Catch both a === "" and a === null, depending on the browser's result for getAttributeNS
    a = undefined;
}
``