mythz/jquip

seems bug in data method

Closed this issue · 2 comments

    function data(el, name, setVal){
        if (!el) return {};
        if (name && setVal){
            el.setAttribute(name, setVal);
            return null;
        }
        var o = {};
        _each(attrs(el), function(val, aName){
            if (aName.indexOf("data-") !== 0 || !val) return;
            o[aName.substr("data-".length)] = val;
        });
        if (isS(name)) return o[name];
        return o;
    } $['data'] = data;

by the above logic, you have to use this method like:

set: $.data(document.body, 'data-sample', 'sample')
get: $.data(document.body, 'sample')

which I don't think is the right way it's supposed to work.

sure, send a pull request of what you think it should be.

This is no longer applicable. The issue was originally fixed in :
9172cea

Also, now data() no longer writes to data- attributes.