JQuery Upgrade, .attr and .prop - from 1.2.6 to 1.9.1

I am 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). Everything is going well - the Migration script does most of the work, although this is only for 1.6.4 to 1.9.1, I think I have most of the other changes that need to be sorted.

There are several problems that I encountered, the main one being changes from .attr()to .prop()- because all of our code uses .attr()some interruptions if we just change it to use .prop (), in particular some links that are used to filter products in store — they make AJAX calls and do other processing when clicked.

My initial “fix” (in EXTREMELY large air quotes) was based on simply redirecting calls from one to another:

$.fn.attr = $.fn.prop;

I am sure that this introduces a whole world of errors, although he corrected what was originally violated. Since then, I noticed only one error caused by it (for now, one way or another), which means that it calls the href attribute (which can be an anchor starting with C #) to return the full normalized URL - http: / /jsfiddle.net/eT6xE/1/

<a href="#something"><span>Product Details</span></a>
<div></div>

$('div').append( $('a').attr('href') );
$('div').append( '<br />' + $('a').prop('href') );
// #something  \n  http://fiddle.jshell.net/eT6xE/1/show/#something

, , , - http://jsfiddle.net/M92CE/1/ - . , href attr/prop, , ... , .

- "" , , ?

.

+5
1

jQuery 1.9 , . jQuery 1.2 1.9, , .

, jQuery 1.9 jQuery Migrate , , 1.9.

jQuery, jQuery Migrate, .

, Migrate - , . Migrate, , , Migrate.

, , , Migrate , , .

Hope this helps.

+5
source

All Articles