I noticed some typo so here corrected versions: $.data(elem, readOnly) -> http://pastebin.com/fa43da97 $.data(elem, name) -> http://pastebin.com/f758b264 $.data(elem, name, data) -> http://pastebin.com/f3deb2895
If I am the only one to think that getting a value would not causing data object creation, then $.data(elem) is certainly my favorite candidate (with no name and data arguments). On Oct 18, 11:38 am, Robert Katić <robert.ka...@gmail.com> wrote: > I played a little on some variations of $.data() API and concluded > with these: > > $.data(elem, readOnly) ->http://pastebin.com/f323becaa > $.data(elem, name) ->http://pastebin.com/f498f9a65 > $.data(elem, name, data) ->http://pastebin.com/f6b474da8 > > I didn't tested/profiled it yet, but if we consider $.data() a "low > level" part of API, then I prefer firs version. > > Opinions? > > On Oct 18, 2:57 am, Robert Katić <robert.ka...@gmail.com> wrote: > > > Yes there is a big error in my code. Here is new > > onehttp://pastebin.com/d66929de4 > > > On Oct 18, 1:27 am, Robert Katić <robert.ka...@gmail.com> wrote: > > > > If I was not clear enough here are some codehttp://pastebin.com/m14c0aa3b > > > > PS: For now, I am not sure if new Number(...) is necessary and that it > > > is safe enough. > > > > On Oct 18, 1:05 am, Robert Katić <robert.ka...@gmail.com> wrote: > > > > > I am certainly in favor to that that $.data(elem) returns data object > > > > instead of id. > > > > > I would like that $.data() will not handle getting/setting too, but > > > > then we would probably consider how to handle getting without > > > > generating the data object. Maybe an $.data(elem, true) to get data > > > > object without creating it? > > > > Because I wouldn't like to be forced to use $(elem).data(prop) only > > > > because $.fn.data() prevents unnecessary data creations and $.data() > > > > not. > > > > > On Oct 17, 3:40 am, John Resig <jere...@gmail.com> wrote: > > > > > > > Of course, although it would simplify the $.data() implementation > > > > > > (speed performances too) it would breaks compatibility with many > > > > > > existent plugins. However, $.data() in 1.4 will breaks it already... > > > > > > If developers want to switch to this style they're absolutely welcome > > > > > to (in fact, we already have in jQuery core for performance > > > > > advantages, in a number of places). > > > > > > I've done a quick search on Google Code Search and have only found a > > > > > couple places where jQuery.data(elem) is used (outside of jQuery > > > > > itself). Right now I'm leaning towards keeping the API change > > > > > (especially since the alternative would be pretty lame - like doing > > > > > jQuery.data(elem, true) or some such) but if the change is too bad > > > > > then we can always reconsider. > > > > > > I should note that in jQuery 1.4 you can do $(elem).data() to get at > > > > > the element's data, no problem (there was no API conflict for that > > > > > method). > > > > > > --John --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---