Old jQuery.attr('href') functionality

Old jQuery.attr('href') functionality


I'm trying to upgrade a large number of sites at work from very old versions of jQuery (1.2.6, 1.4.3) to the latest version (1.9.1). Things are going pretty well - the Migration script does most of the legwork even though that's only for 1.6.4 to 1.9.1, I think I've got most of the other changes that need sorting.

There's a couple of issues I've run into though, with the main one being the changes from .attr() to .prop() - as all of our code uses .attr() and some breaks if we just change it to use .prop(), specifically some links which are used for filtering products in a store - these invoke AJAX calls and do other processing on being clicked.

My initial "fix" (in EXTREMELY large air-quotes) was based on simply redirecting calls from one to the other:
  1. $.fn.attr = $.fn.prop;
I'm sure this introduces a whole world of bugs, although it fixed that which was initially broken. Since then, I've only noticed one further bug caused by it (so far, anyway), which is that it causes the href attribute (which may be an anchor starting in #) to return the full normalised URL -  http://jsfiddle.net/eT6xE/1/

Given that it's the only bug I've noticed, I've played around a little and come up with a workaround for it -  http://jsfiddle.net/M92CE/1/ - which seems to work in re-introducing the original functionality. Even though that seems like a fairly clean solution for the href attr/prop issue, I can't help but feel that the initial fix is ... a long way short of what it could be.

Is there any "standard" way for re-introducing this functionality, and if not, is there any nicer way of doing it?