Index: src/wp-includes/class-wp-editor.php
===================================================================
--- src/wp-includes/class-wp-editor.php	(revision 41000)
+++ src/wp-includes/class-wp-editor.php	(working copy)
@@ -828,6 +828,7 @@
 			$settings['wpautop'] = false;
 			$settings['indent'] = true;
 			$settings['elementpath'] = false;
+			$settings['wp_pad_empty_elements'] = true;
 
 			if ( is_rtl() ) {
 				$settings['directionality'] = 'rtl';
Index: src/wp-includes/js/tinymce/plugins/wordpress/plugin.js
===================================================================
--- src/wp-includes/js/tinymce/plugins/wordpress/plugin.js	(revision 41000)
+++ src/wp-includes/js/tinymce/plugins/wordpress/plugin.js	(working copy)
@@ -131,6 +131,13 @@
 					'/>';
 				} );
 			}
+
+			// Pad empty <span> and <a> that have attributes so they are not removed on cleanup.
+			if ( editor.settings.wp_pad_empty_elements && event.format !== 'raw' ) {
+				event.content = event.content.replace( /(<(a|span) [^>]+>)<\/\2>/gi, function( match, tag, tagName ) {
+					return tag.concat( '<wbr data-wp-empty-element-padding="1" />', '</', tagName, '>' );
+				});
+			}
 		}
 	});
 
@@ -171,6 +178,11 @@
 				return string || image;
 			});
 		}
+
+		// Remove the padding of empty elements.
+		if ( editor.settings.wp_pad_empty_elements && event.format !== 'raw' ) {
+			event.content = event.content.replace( /<wbr data-wp-empty-element-padding="1" \/>/g, '' );
+		}
 	});
 
 	// Display the tag name instead of img in element path
