var Weakmap = require("weakmap")

    , datasetMap = Weakmap()

module.exports = DataSet

function DataSet(elem) {
    var hash = datasetMap.get(elem)

    if (!hash) {
        hash = createHash(elem)
        datasetMap.set(elem, hash)
    }

    return hash
}

function createHash(elem) {
    var attributes = elem.attributes
        , hash = {}

    if (attributes === null) {
        return hash
    }

    for (var i = 0; i < attributes.length; i++) {
        var attr = attributes[i]

        if (attr.name.substr(0,5) !== "data-") {
            continue
        }

        hash[attr.name.substr(5)] = attr.value
    }

    return hash
}

@@ -368,16 +368,44 @@
 === null
+ %7C%7C attributes === undefined
 ) %7B%0A    

check against undefined