(function(oldVal) { $.fn.val = function(value) { if ( arguments.length ) return oldVal.call( this, value === undefined || value === null ? "" : value ); else return oldVal.call( this ); }; })($.fn.val);
The best way to proxy a function to an old one is using an anonymous function. It's the most reliable way to make sure that any proxying someone else does doesn't cause your proxy to break. The real thing you want to test is the length of the arguments. ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name] vdhant wrote: > I was thinking of something a little more simple. I don't mind doing > this in the shorter time but for the here and now I was wondering how > I would write an in code dynamic patch. > > As in would I do something like the following: > > //This being code I add to my page > jQuery.fn = jQuery.prototype = { > baseval: jQuery.prototype.val, > val: function(value) { > this.basedval(value || ''); > } > }; > > Like I know the above doesn't quite work but is there some way that I > could archive this? > Cheers > Anthony > > On Jun 17, 1:39 pm, David Zhou <da...@nodnod.net> wrote: > >> Checkout the jQuery svn repo, make your changes and generate a diff. >> >> -- dz >> >> On Tue, Jun 16, 2009 at 11:34 PM, vdhant <vdh....@gmail.com> wrote: >> >> >>> Hey guys >>> In the meantime how could I go about creating my own patch that fixes >>> this issue??? >>> Cheers >>> Anthony >>> >>> On Jun 17, 1:11 pm, Daniel Friesen <nadir.seen.f...@gmail.com> wrote: >>> >>>> Hmmm? Clarifying, has $(el).css('width', undefined).someOtherFnMethod(); >>>> been fixed? >>>> >>>> ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name] >>>> >>>> John Resig wrote: >>>> >>>>>> It's always a good idea to either use a ||'' or cast your data to a >>>>>> >>> string or other proper datatype when using jQuery, a large number of the >>> methods will have somewhat undesirable results if you try using null or >>> undefined, it's a known issue. >>> >>>>> Oh, I wouldn't go that far. We've patched any null/undefined issues >>>>> that we've found. I'm not aware of any outstanding issues (save for >>>>> the one mentioned in this thread). Pointers to any others would be >>>>> appreciated. >>>>> >>>>> vdhant: You should file a bug with this point in it: >>>>> http://dev.jquery.com/newticket >>>>> >>>>> --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 -~----------~----~----~----~------~----~------~--~---