From 49c6bc2a694e78561fc249562e7f3868db5ad154 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 15 Dec 2019 08:43:42 +0000 Subject: [PATCH] Coding Standards: Add missing braces to `if` conditions in `js/_enqueues/wp/util.js`. Props ankitmaru. Fixes #48980. git-svn-id: https://develop.svn.wordpress.org/trunk@46960 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/wp/util.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/js/_enqueues/wp/util.js b/src/js/_enqueues/wp/util.js index 9befe512a1..836d0016f2 100644 --- a/src/js/_enqueues/wp/util.js +++ b/src/js/_enqueues/wp/util.js @@ -94,10 +94,13 @@ window.wp = window.wp || {}; deferred = $.Deferred( function( deferred ) { // Transfer success/error callbacks. - if ( options.success ) + if ( options.success ) { deferred.done( options.success ); - if ( options.error ) + } + + if ( options.error ) { deferred.fail( options.error ); + } delete options.success; delete options.error; @@ -105,13 +108,15 @@ window.wp = window.wp || {}; // Use with PHP's wp_send_json_success() and wp_send_json_error() deferred.jqXHR = $.ajax( options ).done( function( response ) { // Treat a response of 1 as successful for backward compatibility with existing handlers. - if ( response === '1' || response === 1 ) + if ( response === '1' || response === 1 ) { response = { success: true }; + } - if ( _.isObject( response ) && ! _.isUndefined( response.success ) ) + if ( _.isObject( response ) && ! _.isUndefined( response.success ) ) { deferred[ response.success ? 'resolveWith' : 'rejectWith' ]( this, [response.data] ); - else + } else { deferred.rejectWith( this, [response] ); + } }).fail( function() { deferred.rejectWith( this, arguments ); });