From ceb892533f0624bbb3b74fc410203803f2314208 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Wed, 13 Jan 2016 16:16:15 +0000 Subject: [PATCH] jQuery: Replace the use of the `.size()` method with the `.length` property. The `.size()` method is deprecated since jQuery 1.8. The `.length` property is preferred because it doesn't have the overhead of a function call. See https://api.jquery.com/size/. See #35380. git-svn-id: https://develop.svn.wordpress.org/trunk@36286 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/common.js | 2 +- src/wp-admin/js/edit-comments.js | 2 +- src/wp-admin/js/media-upload.js | 2 +- src/wp-admin/js/plugin-install.js | 2 +- src/wp-admin/js/post.js | 2 +- src/wp-includes/js/wp-ajax-response.js | 6 +++--- src/wp-includes/js/wp-lists.js | 14 +++++++------- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/wp-admin/js/common.js b/src/wp-admin/js/common.js index 6f66aeec8f..9fa67e5b65 100644 --- a/src/wp-admin/js/common.js +++ b/src/wp-admin/js/common.js @@ -83,7 +83,7 @@ validateForm = function( form ) { .addClass( 'form-invalid' ) .find( 'input:visible' ) .change( function() { $( this ).closest( '.form-invalid' ).removeClass( 'form-invalid' ); } ) - .size(); + .length; }; // stub for doing better warnings diff --git a/src/wp-admin/js/edit-comments.js b/src/wp-admin/js/edit-comments.js index 7fc62deb73..dd3025f194 100644 --- a/src/wp-admin/js/edit-comments.js +++ b/src/wp-admin/js/edit-comments.js @@ -481,7 +481,7 @@ setCommentsList = function() { } } - if ( ! theExtraList || theExtraList.size() === 0 || theExtraList.children().size() === 0 ) { + if ( ! theExtraList || theExtraList.length === 0 || theExtraList.children().length === 0 ) { return; } diff --git a/src/wp-admin/js/media-upload.js b/src/wp-admin/js/media-upload.js index 011b618ff5..cd969b9b3a 100644 --- a/src/wp-admin/js/media-upload.js +++ b/src/wp-admin/js/media-upload.js @@ -47,7 +47,7 @@ var tb_position; adminbar_height = parseInt( $('#wpadminbar').css('height'), 10 ); } - if ( tbWindow.size() ) { + if ( tbWindow.length ) { tbWindow.width( W - 50 ).height( H - 45 - adminbar_height ); $('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height ); tbWindow.css({'margin-left': '-' + parseInt( ( ( W - 50 ) / 2 ), 10 ) + 'px'}); diff --git a/src/wp-admin/js/plugin-install.js b/src/wp-admin/js/plugin-install.js index e9186cde1c..6693598e17 100644 --- a/src/wp-admin/js/plugin-install.js +++ b/src/wp-admin/js/plugin-install.js @@ -9,7 +9,7 @@ jQuery( document ).ready( function( $ ) { H = $( window ).height() - ( ( 792 < width ) ? 60 : 20 ), W = ( 792 < width ) ? 772 : width - 20; - if ( tbWindow.size() ) { + if ( tbWindow.length ) { tbWindow.width( W ).height( H ); $( '#TB_iframeContent' ).width( W ).height( H ); tbWindow.css({ diff --git a/src/wp-admin/js/post.js b/src/wp-admin/js/post.js index ae5e097cf6..0d7bf0359c 100644 --- a/src/wp-admin/js/post.js +++ b/src/wp-admin/js/post.js @@ -73,7 +73,7 @@ WPSetThumbnailHTML = function(html){ WPSetThumbnailID = function(id){ var field = $('input[value="_thumbnail_id"]', '#list-table'); - if ( field.size() > 0 ) { + if ( field.length > 0 ) { $('#meta\\[' + field.attr('id').match(/[0-9]+/) + '\\]\\[value\\]').text(id); } }; diff --git a/src/wp-includes/js/wp-ajax-response.js b/src/wp-includes/js/wp-ajax-response.js index 31fc897e6f..d35632102b 100644 --- a/src/wp-includes/js/wp-ajax-response.js +++ b/src/wp-includes/js/wp-ajax-response.js @@ -24,7 +24,7 @@ var wpAjax = jQuery.extend( { response.supplemental = {}; if ( !jQuery( 'supplemental', child ).children().each( function() { response.supplemental[this.nodeName] = jQuery(this).text(); - } ).size() ) { response.supplemental = false; } + } ).length ) { response.supplemental = false; } response.errors = []; if ( !jQuery('wp_error', child).each( function() { var code = jQuery(this).attr('code'), anError, errorData, formField; @@ -37,7 +37,7 @@ var wpAjax = jQuery.extend( { err += '

' + anError.message + '

'; response.errors.push( anError ); parsed.errors = true; - } ).size() ) { response.errors = false; } + } ).length ) { response.errors = false; } parsed.responses.push( response ); } ); if ( err.length ) { re.html( '
' + err + '
' ); } @@ -54,7 +54,7 @@ var wpAjax = jQuery.extend( { }, validateForm: function( selector ) { selector = jQuery( selector ); - return !wpAjax.invalidateForm( selector.find('.form-required').filter( function() { return jQuery('input:visible', this).val() === ''; } ) ).size(); + return !wpAjax.invalidateForm( selector.find('.form-required').filter( function() { return jQuery('input:visible', this).val() === ''; } ) ).length; } }, wpAjax || { noPerm: 'You do not have permission to do that.', broken: 'An unidentified error has occurred.' } ); diff --git a/src/wp-includes/js/wp-lists.js b/src/wp-includes/js/wp-lists.js index bf34b8c4b9..117e892f72 100644 --- a/src/wp-includes/js/wp-lists.js +++ b/src/wp-includes/js/wp-lists.js @@ -336,16 +336,16 @@ wpList = { s = $.extend(_s, this.wpList.settings, s); - if ( !e.size() || !s.what ) + if ( !e.length || !s.what ) return false; if ( s.oldId ) old = $('#' + s.what + '-' + s.oldId); - if ( s.id && ( s.id != s.oldId || !old || !old.size() ) ) + if ( s.id && ( s.id != s.oldId || !old || !old.length ) ) $('#' + s.what + '-' + s.id).remove(); - if ( old && old.size() ) { + if ( old && old.length ) { old.before(e); old.remove(); } else if ( isNaN(s.pos) ) { @@ -358,7 +358,7 @@ wpList = { ref = list.find( '#' + s.pos ); - if ( 1 === ref.size() ) + if ( 1 === ref.length ) ref[ba](e); else list.append(e); @@ -389,11 +389,11 @@ wpList = { e = $(e); - if ( list.wpList && e.parents( '#' + list.id ).size() ) + if ( list.wpList && e.parents( '#' + list.id ).length ) return; e.find(':input').each( function() { - if ( $(this).parents('.form-no-clear').size() ) + if ( $(this).parents('.form-no-clear').length ) return; t = this.type.toLowerCase(); @@ -437,7 +437,7 @@ wpList = { items = $('.list-item:visible', list); - if ( !items.size() ) + if ( !items.length ) items = $(list).children(':visible'); eo = [':even',':odd'];