hyyan / woo-poly-integration

Looking for maintainers! - Wordpress WooCommerce Polylang Integration
https://wordpress.org/plugins-wp/woo-poly-integration/
MIT License
183 stars 66 forks source link

.bind() is deprecated in recent versions of jQuery #530

Closed mrleemon closed 3 years ago

mrleemon commented 3 years ago

As of jQuery 3.0, .bind() has been deprecated. It was superseded by the .on() method for attaching event handlers to a document. In /public/js/Cart.js and /public/js/Cart.min.js there is a reference to .bind() that should be changed to .on() in order to work with recent versions of WP:

https://github.com/hyyan/woo-poly-integration/blob/383d3aa7ab16f9811344ed84ebb42539ec9e6b60/public/js/Cart.js#L225

wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function() {

should be:

wp.customize.selectiveRefresh.on( 'partial-content-rendered', function() {

Jon007 commented 3 years ago

fair enough, looks like this fix will be in WooCommerce 5.. was changed a couple of days ago in: https://github.com/woocommerce/woocommerce/blob/master/assets/js/frontend/cart-fragments.js [this plugin file is copy of that with a few extra lines, I had diff-d to release version which didn't have these changes]

Jon007 commented 3 years ago

actually woocommerce 5.0.0-rc.2 still has .bind, maybe wait for their code to stabilise

mrleemon commented 3 years ago

I didn't know that, sorry. Yes, I see that WC 5.0 is supposed to fix all the jQuery deprecations.

https://github.com/woocommerce/woocommerce/pull/28753

mrleemon commented 3 years ago

According to this:

https://github.com/woocommerce/woocommerce/commit/5c76d8df59335118964b897d17978df5486c43c1#diff-99ceea56db3e2a3c60b44859f294c6fcf2b3c63308a45768180db41362b51168

the bind() in Cart.js doesn't have to be replaced because wp.customize.selectiveRefresh is not a jQuery object.