From ab5685e6ad888b6a6ed155c0eaad734efea3fae1 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sat, 18 Apr 2015 21:55:45 +0000 Subject: [PATCH] TinyMCE: remove the empty paragraph that sometimes is left over after adding an image caption. Fixes #32003. git-svn-id: https://develop.svn.wordpress.org/trunk@32141 602fd350-edb4-49c9-b593-d223f7449a82 --- .../js/tinymce/plugins/wpeditimage/plugin.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js index a23c077a4d..025603b41e 100644 --- a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js @@ -452,15 +452,15 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { if ( parent = dom.getParent( node, 'p' ) ) { parent.parentNode.insertBefore( wrap, parent ); - - if ( dom.isEmpty( parent ) ) { - dom.remove( parent ); - } } else { node.parentNode.insertBefore( wrap, node ); } editor.$( wrap ).find( 'dt.wp-caption-dt' ).append( node ); + + if ( parent && dom.isEmpty( parent ) ) { + dom.remove( parent ); + } } } else if ( captionNode ) { // Remove the caption wrapper and place the image in new paragraph @@ -734,15 +734,15 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { if ( parent = dom.getParent( node, 'p' ) ) { parent.parentNode.insertBefore( wrap, parent ); - - if ( dom.isEmpty( parent ) ) { - dom.remove( parent ); - } } else { node.parentNode.insertBefore( wrap, node ); } editor.$( wrap ).find( 'dt.wp-caption-dt' ).append( node ); + + if ( parent && dom.isEmpty( parent ) ) { + dom.remove( parent ); + } } } else { if ( wrap ) {