jenkins-bot has submitted this change and it was merged.
Change subject: Disconnect bound reference list events on teardown
......................................................................
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
---
M modules/ve/ce/nodes/ve.ce.MWReferenceListNode.js
1 file changed, 37 insertions(+), 7 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve/ce/nodes/ve.ce.MWReferenceListNode.js
b/modules/ve/ce/nodes/ve.ce.MWReferenceListNode.js
index 10c936f..0cf90c9 100644
--- a/modules/ve/ce/nodes/ve.ce.MWReferenceListNode.js
+++ b/modules/ve/ce/nodes/ve.ce.MWReferenceListNode.js
@@ -24,19 +24,17 @@
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();
};
@@ -57,6 +55,38 @@
/* 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.
*
* This will occur after a document transaction.
--
To view, visit https://gerrit.wikimedia.org/r/71660
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ieb0354938b68fe5e7965f61f9ccce07cd6fb1120
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Trevor Parscal <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits