mythz/jquip — Issue #20: seems bug in data method
Author: lanyuyang
Created: 2012-03-09 07:49:21+00:00
State: open

```javascript
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.