Replace all occurrences of jQuery.parseJSON()

jQuery.parseJSON() is deprecated (https://api.jquery.com/jquery.parsejson/). This commit replaces all of its occurrences with JSON.parse().
This commit is contained in:
Rodrigo Primo 2020-10-22 10:11:27 -03:00
parent 05cc0882e5
commit 291884e154
6 changed files with 7 additions and 7 deletions

View File

@ -19,7 +19,7 @@ jQuery( function ( $ ) {
) )
) { ) {
/* State/Country select boxes */ /* State/Country select boxes */
this.states = $.parseJSON( woocommerce_admin_meta_boxes_order.countries.replace( /"/g, '"' ) ); this.states = JSON.parse( woocommerce_admin_meta_boxes_order.countries.replace( /"/g, '"' ) );
} }
$( '.js_field-country' ).selectWoo().change( this.change_country ); $( '.js_field-country' ).selectWoo().change( this.change_country );

View File

@ -9,7 +9,7 @@ jQuery( function ( $ ) {
init: function() { init: function() {
if ( typeof wc_users_params.countries !== 'undefined' ) { if ( typeof wc_users_params.countries !== 'undefined' ) {
/* State/Country select boxes */ /* State/Country select boxes */
this.states = $.parseJSON( wc_users_params.countries.replace( /"/g, '"' ) ); this.states = JSON.parse( wc_users_params.countries.replace( /"/g, '"' ) );
} }
$( '.js_field-country' ).selectWoo().change( this.change_country ); $( '.js_field-country' ).selectWoo().change( this.change_country );

View File

@ -6,7 +6,7 @@ jQuery( function( $ ) {
return false; return false;
} }
var locale_json = wc_address_i18n_params.locale.replace( /"/g, '"' ), locale = $.parseJSON( locale_json ); var locale_json = wc_address_i18n_params.locale.replace( /"/g, '"' ), locale = JSON.parse( locale_json );
function field_is_required( field, is_required ) { function field_is_required( field, is_required ) {
if ( is_required ) { if ( is_required ) {
@ -51,7 +51,7 @@ jQuery( function( $ ) {
$statefield.attr( 'data-o_class', $statefield.attr( 'class' ) ); $statefield.attr( 'data-o_class', $statefield.attr( 'class' ) );
} }
var locale_fields = $.parseJSON( wc_address_i18n_params.locale_fields ); var locale_fields = JSON.parse( wc_address_i18n_params.locale_fields );
$.each( locale_fields, function( key, value ) { $.each( locale_fields, function( key, value ) {

View File

@ -115,7 +115,7 @@ jQuery( function( $ ) {
} ); } );
try { try {
var wc_fragments = $.parseJSON( sessionStorage.getItem( wc_cart_fragments_params.fragment_name ) ), var wc_fragments = JSON.parse( sessionStorage.getItem( wc_cart_fragments_params.fragment_name ) ),
cart_hash = sessionStorage.getItem( cart_hash_key ), cart_hash = sessionStorage.getItem( cart_hash_key ),
cookie_hash = Cookies.get( 'woocommerce_cart_hash'), cookie_hash = Cookies.get( 'woocommerce_cart_hash'),
cart_created = sessionStorage.getItem( 'wc_cart_created' ); cart_created = sessionStorage.getItem( 'wc_cart_created' );

View File

@ -191,7 +191,7 @@ jQuery( function( $ ) {
}, },
is_valid_json: function( raw_json ) { is_valid_json: function( raw_json ) {
try { try {
var json = $.parseJSON( raw_json ); var json = JSON.parse( raw_json );
return ( json && 'object' === typeof json ); return ( json && 'object' === typeof json );
} catch ( e ) { } catch ( e ) {

View File

@ -77,7 +77,7 @@ jQuery( function( $ ) {
/* State/Country select boxes */ /* State/Country select boxes */
var states_json = wc_country_select_params.countries.replace( /"/g, '"' ), var states_json = wc_country_select_params.countries.replace( /"/g, '"' ),
states = $.parseJSON( states_json ), states = JSON.parse( states_json ),
wrapper_selectors = '.woocommerce-billing-fields,' + wrapper_selectors = '.woocommerce-billing-fields,' +
'.woocommerce-shipping-fields,' + '.woocommerce-shipping-fields,' +
'.woocommerce-address-fields,' + '.woocommerce-address-fields,' +