Make WordPress Core

Changeset 26228


Ignore:
Timestamp:
11/15/2013 09:24:43 PM (11 years ago)
Author:
nacin
Message:

Fix JSHint errors in shortcode.js.

props tommcfarlin.
fixes #25945.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/shortcode.js

    r22798 r26228  
    2020            match = re.exec( text );
    2121
    22             if ( ! match )
     22            if ( ! match ) {
    2323                return;
     24            }
    2425
    2526            // If we matched an escaped shortcode, try again.
    26             if ( match[1] === '[' && match[7] === ']' )
     27            if ( '[' === match[1] && ']' === match[7] ) {
    2728                return wp.shortcode.next( tag, text, re.lastIndex );
     29            }
    2830
    2931            result = {
     
    4143
    4244            // If we matched a trailing `]`, strip it from the match.
    43             if ( match[7] )
     45            if ( match[7] ) {
    4446                result.match = result.match.slice( 0, -1 );
     47            }
    4548
    4649            return result;
     
    5760        // and a boolean flag to indicate if the match was a `single` tag.
    5861        replace: function( tag, text, callback ) {
    59             return text.replace( wp.shortcode.regexp( tag ), function( match, left, tag, attrs, slash, content, closing, right, offset ) {
     62            return text.replace( wp.shortcode.regexp( tag ), function( match, left, tag, attrs, slash, content, closing, right ) {
    6063                // If both extra brackets exist, the shortcode has been
    6164                // properly escaped.
    62                 if ( left === '[' && right === ']' )
     65                if ( left === '[' && right === ']' ) {
    6366                    return match;
     67                }
    6468
    6569                // Create the match object and pass it through the callback.
     
    165169            var type;
    166170
    167             if ( match[4] )
     171            if ( match[4] ) {
    168172                type = 'self-closing';
    169             else if ( match[6] )
     173            } else if ( match[6] ) {
    170174                type = 'closed';
    171             else
     175            } else {
    172176                type = 'single';
     177            }
    173178
    174179            return new wp.shortcode({
     
    203208        };
    204209
    205         if ( ! attrs )
     210        if ( ! attrs ) {
    206211            return;
     212        }
    207213
    208214        // Parse a string of attributes.
     
    245251
    246252            _.each( this.attrs.numeric, function( value ) {
    247                 if ( /\s/.test( value ) )
     253                if ( /\s/.test( value ) ) {
    248254                    text += ' "' + value + '"';
    249                 else
     255                } else {
    250256                    text += ' ' + value;
     257                }
    251258            });
    252259
     
    257264            // If the tag is marked as `single` or `self-closing`, close the
    258265            // tag and ignore any additional content.
    259             if ( 'single' === this.type )
     266            if ( 'single' === this.type ) {
    260267                return text + ']';
    261             else if ( 'self-closing' === this.type )
     268            } else if ( 'self-closing' === this.type ) {
    262269                return text + ' /]';
     270            }
    263271
    264272            // Complete the opening tag.
    265273            text += ']';
    266274
    267             if ( this.content )
     275            if ( this.content ) {
    268276                text += this.content;
     277            }
    269278
    270279            // Add the closing tag.
     
    292301
    293302            // If `content` ends in a slash, strip it.
    294             if ( '/' === content[ content.length - 1 ] )
     303            if ( '/' === content[ content.length - 1 ] ) {
    295304                content = content.slice( 0, -1 );
     305            }
    296306
    297307            result = wp.shortcode.attrs( content );
     
    299309
    300310            _.each( result.numeric, function( key ) {
    301                 if ( /\s/.test( key ) )
     311                if ( /\s/.test( key ) ) {
    302312                    return;
     313                }
    303314
    304315                attrs[ key ] = '';
     
    317328
    318329                // Use empty attribute notation where possible.
    319                 if ( '' === value )
     330                if ( '' === value ) {
    320331                    return;
     332                }
    321333
    322334                // Convert boolean values to strings.
    323                 if ( _.isBoolean( value ) )
     335                if ( _.isBoolean( value ) ) {
    324336                    value = value ? 'true' : 'false';
     337                }
    325338
    326339                text += '="' + value + '"';
     
    328341
    329342            // Return the result if it is a self-closing tag.
    330             if ( options.single )
     343            if ( options.single ) {
    331344                return text + ' />';
     345            }
    332346
    333347            // Complete the opening tag.
Note: See TracChangeset for help on using the changeset viewer.