seems bug in data method
Closed this issue · 2 comments
y-lan commented
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.
mythz commented
sure, send a pull request of what you think it should be.