Ah, I decided it already :)
latest version:
This is somewhat simplified code:
function setData(e,key,data){ if(typeof(e)==string){ e = $(e); } $(e).data(key,data); }
Decision
The problem was that I wanted to keep the ability to add an element via $('element') , 'element' or $(this) , so I had to add a typeof check before setting up the data - just like jQuery works.
if I add an element as soon as the selector , it is $(e) , if I add a jQuery object , it is e :
function setData(e,key,data){ if(typeof(e)==string){ $(e).data(key,data); }else{ e.data(key,data); } }
So, you all will get an advantage, and I will take myself the winner in two days, so anyone who stumbles on this question will know what to do (clearly, verified, working:]) and why :)
Edit : note: This is probably not the final version. I read additional documentation, so this setData function supports all types supported by jQuery.add .
source share