Catrope has uploaded a new change for review.

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

Change subject: Make ce.BranchNode#updateTagName do what its documentation says
......................................................................

Make ce.BranchNode#updateTagName do what its documentation says

Actually transfer classes, and transfer the contentEditable property too.
This allows us to set classes and cE in the constructor instead
of on setup.

Change-Id: I7547a2228754332b907f36d9705b9987b12d1091
---
M src/ce/ve.ce.BranchNode.js
1 file changed, 11 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/24/193824/1

diff --git a/src/ce/ve.ce.BranchNode.js b/src/ce/ve.ce.BranchNode.js
index f87a6ff..46fc5bb 100644
--- a/src/ce/ve.ce.BranchNode.js
+++ b/src/ce/ve.ce.BranchNode.js
@@ -117,10 +117,10 @@
 /**
  * Update the DOM wrapper.
  *
- * WARNING: The contents, .data( 'view' ) and any classes the wrapper already 
has will be moved to
- * the new wrapper, but other attributes and any other information added using 
$.data() will be
- * lost upon updating the wrapper. To retain information added to the wrapper, 
subscribe to the
- * 'teardown' and 'setup' events.
+ * WARNING: The contents, .data( 'view' ), the contentEditable property and 
any classes the wrapper
+ * already has will be moved to  the new wrapper, but other attributes and any 
other information
+ * added using $.data() will be lost upon updating the wrapper. To retain 
information added to the
+ * wrapper, subscribe to the 'teardown' and 'setup' events.
  *
  * @method
  * @fires teardown
@@ -132,9 +132,13 @@
 
        if ( tagName !== this.tagName ) {
                this.emit( 'teardown' );
-               $wrapper = this.$( document.createElement( tagName ) );
-               // Move contents
-               $wrapper.append( this.$element.contents() );
+               $wrapper = this.$( document.createElement( tagName ) )
+                       // Move contents
+                       .append( this.$element.contents() )
+                       // Copy classes
+                       .prop( 'class', this.$element.prop( 'class' ) )
+                       // Copy contentEditable
+                       .prop( 'contentEditable', this.$element.prop( 
'contentEditable' ) );
                // Swap elements
                this.$element.replaceWith( $wrapper );
                // Use new element from now on

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7547a2228754332b907f36d9705b9987b12d1091
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to