Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/200304

Change subject: Unwrap empty spans on paste
......................................................................

Unwrap empty spans on paste

These are unlikely to be meaningful and are more likely
generated garbage from CE. In most cases they are thrown away
by the sanitizer, but in paste from another VE instance that
doesn't happen.

Change-Id: I8fafb06549abb12d63911a6f0f50fd57b9b6a307
---
M src/ce/ve.ce.Surface.js
1 file changed, 10 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/04/200304/1

diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index 55ee6b8..376ac39 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -1833,12 +1833,19 @@
                return;
        }
 
-       // Remove the pasteProtect class. See #onCopy.
-       this.$pasteTarget.find( 'span' ).removeClass( 've-pasteProtect' );
-
        // Remove style attributes. Any valid styles will be restored by 
data-ve-attributes.
        this.$pasteTarget.find( '[style]' ).removeAttr( 'style' );
 
+       // Remove the pasteProtect class. See #onCopy.
+       this.$pasteTarget.find( 'span' ).each( function () {
+               var $this = $( this );
+               $this.removeClass( 've-pasteProtect' );
+               // Unwrap empty spans
+               if ( !this.attributes.length ) {
+                       $this.replaceWith( this.childNodes );
+               }
+       } );
+
        // Restore attributes. See #onCopy.
        this.$pasteTarget.find( '[data-ve-attributes]' ).each( function () {
                var attrs;

-- 
To view, visit https://gerrit.wikimedia.org/r/200304
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8fafb06549abb12d63911a6f0f50fd57b9b6a307
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <esand...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to