Make WordPress Core

Changeset 36286


Ignore:
Timestamp:
01/13/2016 04:16:15 PM (9 years ago)
Author:
ocean90
Message:

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.

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/common.js

    r36134 r36286  
    8484        .find( 'input:visible' )
    8585        .change( function() { $( this ).closest( '.form-invalid' ).removeClass( 'form-invalid' ); } )
    86         .size();
     86        .length;
    8787};
    8888
  • trunk/src/wp-admin/js/edit-comments.js

    r35615 r36286  
    482482        }
    483483
    484         if ( ! theExtraList || theExtraList.size() === 0 || theExtraList.children().size() === 0 ) {
     484        if ( ! theExtraList || theExtraList.length === 0 || theExtraList.children().length === 0 ) {
    485485            return;
    486486        }
  • trunk/src/wp-admin/js/media-upload.js

    r28830 r36286  
    4848        }
    4949
    50         if ( tbWindow.size() ) {
     50        if ( tbWindow.length ) {
    5151            tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
    5252            $('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
  • trunk/src/wp-admin/js/plugin-install.js

    r35198 r36286  
    1010            W = ( 792 < width ) ? 772 : width - 20;
    1111
    12         if ( tbWindow.size() ) {
     12        if ( tbWindow.length ) {
    1313            tbWindow.width( W ).height( H );
    1414            $( '#TB_iframeContent' ).width( W ).height( H );
  • trunk/src/wp-admin/js/post.js

    r36227 r36286  
    7474WPSetThumbnailID = function(id){
    7575    var field = $('input[value="_thumbnail_id"]', '#list-table');
    76     if ( field.size() > 0 ) {
     76    if ( field.length > 0 ) {
    7777        $('#meta\\[' + field.attr('id').match(/[0-9]+/) + '\\]\\[value\\]').text(id);
    7878    }
  • trunk/src/wp-includes/js/wp-ajax-response.js

    r34114 r36286  
    2525                if ( !jQuery( 'supplemental', child ).children().each( function() {
    2626                    response.supplemental[this.nodeName] = jQuery(this).text();
    27                 } ).size() ) { response.supplemental = false; }
     27                } ).length ) { response.supplemental = false; }
    2828                response.errors = [];
    2929                if ( !jQuery('wp_error', child).each( function() {
     
    3838                    response.errors.push( anError );
    3939                    parsed.errors = true;
    40                 } ).size() ) { response.errors = false; }
     40                } ).length ) { response.errors = false; }
    4141                parsed.responses.push( response );
    4242            } );
     
    5555    validateForm: function( selector ) {
    5656        selector = jQuery( selector );
    57         return !wpAjax.invalidateForm( selector.find('.form-required').filter( function() { return jQuery('input:visible', this).val() === ''; } ) ).size();
     57        return !wpAjax.invalidateForm( selector.find('.form-required').filter( function() { return jQuery('input:visible', this).val() === ''; } ) ).length;
    5858    }
    5959}, wpAjax || { noPerm: 'You do not have permission to do that.', broken: 'An unidentified error has occurred.' } );
  • trunk/src/wp-includes/js/wp-lists.js

    r36229 r36286  
    337337        s = $.extend(_s, this.wpList.settings, s);
    338338
    339         if ( !e.size() || !s.what )
     339        if ( !e.length || !s.what )
    340340            return false;
    341341
     
    343343            old = $('#' + s.what + '-' + s.oldId);
    344344
    345         if ( s.id && ( s.id != s.oldId || !old || !old.size() ) )
     345        if ( s.id && ( s.id != s.oldId || !old || !old.length ) )
    346346            $('#' + s.what + '-' + s.id).remove();
    347347
    348         if ( old && old.size() ) {
     348        if ( old && old.length ) {
    349349            old.before(e);
    350350            old.remove();
     
    359359            ref = list.find( '#' + s.pos );
    360360
    361             if ( 1 === ref.size() )
     361            if ( 1 === ref.length )
    362362                ref[ba](e);
    363363            else
     
    390390        e = $(e);
    391391
    392         if ( list.wpList && e.parents( '#' + list.id ).size() )
     392        if ( list.wpList && e.parents( '#' + list.id ).length )
    393393            return;
    394394
    395395        e.find(':input').each( function() {
    396             if ( $(this).parents('.form-no-clear').size() )
     396            if ( $(this).parents('.form-no-clear').length )
    397397                return;
    398398
     
    438438        items = $('.list-item:visible', list);
    439439
    440         if ( !items.size() )
     440        if ( !items.length )
    441441            items = $(list).children(':visible');
    442442
Note: See TracChangeset for help on using the changeset viewer.