Skip to content

Commit

Permalink
Better recursion logic when cleaning widget richtext.
Browse files Browse the repository at this point in the history
  • Loading branch information
boonebgorges committed Apr 4, 2016
1 parent 2d43a56 commit ea4ea42
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions assets/js/cacap.js
Expand Up @@ -255,17 +255,16 @@ window.wp = window.wp || {};
var $content = $( content );
var clean_content = '';

// Recurse.
$content.children( 'div' ).each( function( k, v ) {
clean_content += self.clean_content( v );
} );

// If this is a div that's just wrapper for another div, discard the wrapper.
if ( 'DIV' == $content[0].tagName ) {
var $dcontent = $content.children( 'div' );
if ( 1 == $dcontent.length && 'DIV' === $dcontent[0].tagName ) {
clean_content += $dcontent.html();
clean_content += self.clean_content( $dcontent.html() );
} else {
clean_content += content;
}
} else {
clean_content += content;
}

return clean_content;
Expand Down

0 comments on commit ea4ea42

Please sign in to comment.