strangerstudios / paid-memberships-pro

The Trusted Membership Platform That Grows with You: Restrict access to content and charge recurring subscriptions using Stripe, PayPal, and more. Fully open source. 100% GPL.
https://www.paidmembershipspro.com
Other
468 stars 360 forks source link

Use prop() instead of the deprecated attr() for DOM properties such as the checked, selected, readonly or disabled states #1975

Open mrleemon opened 2 years ago

mrleemon commented 2 years ago

According to this link https://api.jquery.com/attr/:

As of jQuery 1.6, the .attr() method returns undefined for attributes that have not been set. To retrieve and change DOM properties such as the checked, selected, readonly or disabled state of form elements, use the [.prop()](https://api.jquery.com/prop/) method.

In your jQuery code there are some parts where attr() is used instead of the correct prop() for getting and setting these states.

Some examples:

https://github.com/strangerstudios/paid-memberships-pro/blob/1504409e7833f9304922b828b22249a1b625cb28/includes/profile.php#L185

https://github.com/strangerstudios/paid-memberships-pro/blob/4812f157e759a38b2d22cf56be728cc00592af07/js/pmpro-checkout.js#L39

https://github.com/strangerstudios/paid-memberships-pro/blob/4812f157e759a38b2d22cf56be728cc00592af07/js/pmpro-checkout.js#L49

https://github.com/strangerstudios/paid-memberships-pro/blob/38c18597d4b0eee457d777f67c3223a9b42e28b4/js/pmpro-admin.js#L429

mircobabini commented 2 years ago

This one is nice too. Gonna take a look, I was not 100% aware of it.

Thanks!