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
This commit is contained in:
Dominik Schilling (ocean90) 2016-01-13 16:16:15 +00:00
parent 3e571a393f
commit ceb892533f
7 changed files with 15 additions and 15 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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'});

View File

@ -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({

View File

@ -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);
}
};

View File

@ -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 += '<p>' + anError.message + '</p>';
response.errors.push( anError );
parsed.errors = true;
} ).size() ) { response.errors = false; }
} ).length ) { response.errors = false; }
parsed.responses.push( response );
} );
if ( err.length ) { re.html( '<div class="error">' + err + '</div>' ); }
@ -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.' } );

View File

@ -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'];