Skip to content

Commit

Permalink
Remove unneccessary each() in getOriginalId()
Browse files Browse the repository at this point in the history
  • Loading branch information
truongwp committed Jun 2, 2017
1 parent b6a2be8 commit 3b30c84
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions js/wysiwyg.js
Expand Up @@ -49,20 +49,17 @@ jQuery( function ( $ ) {
* @param $el Current cloned textarea
*/
function getOriginalId( $el ) {
var $clones = $el.closest( '.rwmb-clone' ),
id = '';
var $clone = $el.closest( '.rwmb-clone' ),
currentId = $clone.find( '.rwmb-wysiwyg' ).attr( 'id' );

$clones.each( function () {
var currentId = $( this ).find( '.rwmb-wysiwyg' ).attr( 'id' );
if ( /_\d+$/.test( currentId ) ) {
currentId = currentId.replace( /_\d+$/, '' );
}
if ( tinyMCEPreInit.mceInit.hasOwnProperty( currentId ) || tinyMCEPreInit.qtInit.hasOwnProperty( currentId ) ) {
id = currentId;
return false; // Immediately stop the .each() loop
}
} );
return id;
if ( /_\d+$/.test( currentId ) ) {
currentId = currentId.replace( /_\d+$/, '' );
}
if ( tinyMCEPreInit.mceInit.hasOwnProperty( currentId ) || tinyMCEPreInit.qtInit.hasOwnProperty( currentId ) ) {
return currentId;
}

return '';
}

/**
Expand Down

0 comments on commit 3b30c84

Please sign in to comment.