mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
Added copying of .data( 'node' ) from old wrappers to new wrappers on wrapper updates
Change-Id: Ibd9535bd9ebb712910d963eedc5941f8512aaf8d
This commit is contained in:
parent
c8ccdb9813
commit
f6eef19021
|
@ -85,14 +85,14 @@ ve.ce.BranchNode.getDomWrapper = function( model, key ) {
|
||||||
*
|
*
|
||||||
* This method uses {getDomWrapperType} to determine the proper element type to use.
|
* This method uses {getDomWrapperType} to determine the proper element type to use.
|
||||||
*
|
*
|
||||||
* WARNING: The contents and any classes the wrapper already has will be moved to the new wrapper, but
|
* WARNING: The contents, .data( 'node' ) and any classes the wrapper already has will be moved to
|
||||||
* other attributes and any information added using $.data() will be lost.
|
* 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
|
||||||
* TODO: Add an event that can be handled to make sure information is copied from the old wrapper
|
* 'rewrap' event and copy information from the {$old} wrapper the {$new} wrapper.
|
||||||
* to the new wrapper.
|
|
||||||
*
|
*
|
||||||
* @method
|
* @method
|
||||||
* @param {String} key Attribute name to read type value from
|
* @param {String} key Attribute name to read type value from
|
||||||
|
* @emits rewrap ($old, $new)
|
||||||
*/
|
*/
|
||||||
ve.ce.BranchNode.prototype.updateDomWrapper = function( key ) {
|
ve.ce.BranchNode.prototype.updateDomWrapper = function( key ) {
|
||||||
var type = ve.ce.BranchNode.getDomWrapperType( this.model, key );
|
var type = ve.ce.BranchNode.getDomWrapperType( this.model, key );
|
||||||
|
@ -100,8 +100,12 @@ ve.ce.BranchNode.prototype.updateDomWrapper = function( key ) {
|
||||||
var $element = $( '<' + type + '></' + type + '>' );
|
var $element = $( '<' + type + '></' + type + '>' );
|
||||||
// Copy classes
|
// Copy classes
|
||||||
$element.attr( 'class', this.$.attr( 'class' ) );
|
$element.attr( 'class', this.$.attr( 'class' ) );
|
||||||
|
// Copy .data( 'node' )
|
||||||
|
$element.data( 'node', this.$.data( 'node' ) );
|
||||||
// Move contents
|
// Move contents
|
||||||
$element.append( this.$.contents() );
|
$element.append( this.$.contents() );
|
||||||
|
// Emit an event that can be handled to copy other things over if needed
|
||||||
|
this.emit( 'rewrap', this.$, $element );
|
||||||
// Swap elements
|
// Swap elements
|
||||||
this.$.replaceWith( $element );
|
this.$.replaceWith( $element );
|
||||||
// Use new element from now on
|
// Use new element from now on
|
||||||
|
|
Loading…
Reference in a new issue