Prevent security error with try catch block Closes #5275

This commit is contained in:
Mike Jolley 2014-04-07 14:34:47 +01:00
parent c4c63982f9
commit 4e075e033a
2 changed files with 6 additions and 2 deletions

View File

@ -6,7 +6,11 @@ jQuery( function( $ ) {
}
/** Cart Handling */
$supports_html5_storage = ( 'sessionStorage' in window && window.sessionStorage !== null );
try {
$supports_html5_storage = ( 'sessionStorage' in window && window.sessionStorage !== null );
} catch( err ) {
$supports_html5_storage = false;
}
$fragment_refresh = {
url: wc_cart_fragments_params.ajax_url,

View File

@ -1 +1 @@
jQuery(function(a){if("undefined"==typeof wc_cart_fragments_params)return!1;if($supports_html5_storage="sessionStorage"in window&&null!==window.sessionStorage,$fragment_refresh={url:wc_cart_fragments_params.ajax_url,type:"POST",data:{action:"woocommerce_get_refreshed_fragments"},success:function(b){b&&b.fragments&&(a.each(b.fragments,function(b,c){a(b).replaceWith(c)}),$supports_html5_storage&&(sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(b.fragments)),sessionStorage.setItem("wc_cart_hash",b.cart_hash)),a("body").trigger("wc_fragments_refreshed"))}},$supports_html5_storage){a("body").bind("added_to_cart",function(a,b,c){sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(b)),sessionStorage.setItem("wc_cart_hash",c)});try{var b=a.parseJSON(sessionStorage.getItem(wc_cart_fragments_params.fragment_name)),c=sessionStorage.getItem("wc_cart_hash"),d=a.cookie("woocommerce_cart_hash");if((null===c||void 0===c||""===c)&&(c=""),(null===d||void 0===d||""===d)&&(d=""),!b||!b["div.widget_shopping_cart_content"]||c!=d)throw"No fragment";a.each(b,function(b,c){a(b).replaceWith(c)}),a("body").trigger("wc_fragments_loaded")}catch(e){a.ajax($fragment_refresh)}}else a.ajax($fragment_refresh);a.cookie("woocommerce_items_in_cart")>0?a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show():a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").hide(),a("body").bind("adding_to_cart",function(){a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show()})});
jQuery(function(a){if("undefined"==typeof wc_cart_fragments_params)return!1;try{$supports_html5_storage="sessionStorage"in window&&null!==window.sessionStorage}catch(b){$supports_html5_storage=!1}if($fragment_refresh={url:wc_cart_fragments_params.ajax_url,type:"POST",data:{action:"woocommerce_get_refreshed_fragments"},success:function(b){b&&b.fragments&&(a.each(b.fragments,function(b,c){a(b).replaceWith(c)}),$supports_html5_storage&&(sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(b.fragments)),sessionStorage.setItem("wc_cart_hash",b.cart_hash)),a("body").trigger("wc_fragments_refreshed"))}},$supports_html5_storage){a("body").bind("added_to_cart",function(a,b,c){sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(b)),sessionStorage.setItem("wc_cart_hash",c)});try{var c=a.parseJSON(sessionStorage.getItem(wc_cart_fragments_params.fragment_name)),d=sessionStorage.getItem("wc_cart_hash"),e=a.cookie("woocommerce_cart_hash");if((null===d||void 0===d||""===d)&&(d=""),(null===e||void 0===e||""===e)&&(e=""),!c||!c["div.widget_shopping_cart_content"]||d!=e)throw"No fragment";a.each(c,function(b,c){a(b).replaceWith(c)}),a("body").trigger("wc_fragments_loaded")}catch(b){a.ajax($fragment_refresh)}}else a.ajax($fragment_refresh);a.cookie("woocommerce_items_in_cart")>0?a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show():a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").hide(),a("body").bind("adding_to_cart",function(){a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show()})});