mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 06:46:26 +00:00
Disconnect bound reference list events on teardown
Reference lists would never disconnect, and some transactions would cause them to be "updated" even though they don't have a document anymore. A way to test this is to insert an image in a document with some references. When you click apply, it crashes. The solution was to make sure we actually disconnect from the internalList and listNode on teardown. Change-Id: Ieb0354938b68fe5e7965f61f9ccce07cd6fb1120
This commit is contained in:
parent
b1859a2f19
commit
9b91bb1cf3
|
@ -24,19 +24,17 @@ ve.ce.MWReferenceListNode = function VeCeMWReferenceListNode( model, config ) {
|
|||
ve.ce.ProtectedNode.call( this );
|
||||
ve.ce.FocusableNode.call( this );
|
||||
|
||||
// DOM Changes
|
||||
// Properties
|
||||
this.internalList = null;
|
||||
this.listNode = null;
|
||||
|
||||
// Initialization
|
||||
this.$
|
||||
.addClass( 've-ce-mwReferenceListNode', 'reference' )
|
||||
.prop( 'contenteditable', false );
|
||||
this.$reflist = $( '<ol class="references"></ol>' );
|
||||
this.$refmsg = $( '<p>' )
|
||||
.addClass( 've-ce-mwReferenceListNode-muted' );
|
||||
|
||||
// Events
|
||||
this.model.getDocument().internalList.connect( this, { 'update': 'onInternalListUpdate' } );
|
||||
this.model.getDocument().internalList.getListNode().connect( this, { 'update': 'onListNodeUpdate' } );
|
||||
|
||||
// Initialization
|
||||
this.update();
|
||||
};
|
||||
|
||||
|
@ -56,6 +54,38 @@ ve.ce.MWReferenceListNode.static.tagName = 'div';
|
|||
|
||||
/* Methods */
|
||||
|
||||
/**
|
||||
* Handle setup events.
|
||||
*
|
||||
* @method
|
||||
*/
|
||||
ve.ce.MWReferenceListNode.prototype.onSetup = function () {
|
||||
this.internalList = this.model.getDocument().getInternalList();
|
||||
this.listNode = this.internalList.getListNode();
|
||||
|
||||
this.internalList.connect( this, { 'update': 'onInternalListUpdate' } );
|
||||
this.listNode.connect( this, { 'update': 'onListNodeUpdate' } );
|
||||
|
||||
// Parent method
|
||||
ve.ce.LeafNode.prototype.onSetup.call( this );
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle teardown events.
|
||||
*
|
||||
* @method
|
||||
*/
|
||||
ve.ce.MWReferenceListNode.prototype.onTeardown = function () {
|
||||
this.internalList.disconnect( this, { 'update': 'onInternalListUpdate' } );
|
||||
this.listNode.disconnect( this, { 'update': 'onListNodeUpdate' } );
|
||||
|
||||
this.internalList = null;
|
||||
this.listNode = null;
|
||||
|
||||
// Parent method
|
||||
ve.ce.LeafNode.prototype.onTeardown.call( this );
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle the updating of the InternalList object.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue