The value of _id_ is a key in _localStorage_, but it might not be the name of a DOM element. If not, _domAttr.set_ throws an exception and the _loadStates_ function quits. This happened when I tested it. I think the fix is to surround lines 48-54 with this:

    if (domAttr.has(id)) {
        //lines 48-54
    }