jenkins-bot has submitted this change and it was merged.
Change subject: Hack around exceptions thrown when closing the reference dialog
......................................................................
Hack around exceptions thrown when closing the reference dialog
ce.ProtectedNode doesn't like to be torn down when it's detached,
and this was happening to CE nodes created in the MWReferenceList.
Hack around this by attaching the CE nodes generated by the
MWReferenceList to the ce.MWReferenceListNode (so they have a
parent and a way of getting to the surface), and by guarding against
multiple successive setups/teardowns in ce.ProtectedNode.
Change-Id: If00e75b939ccbdbaf681bbb6609fec54805bf9a0
---
M modules/ve/ce/nodes/ve.ce.MWReferenceListNode.js
M modules/ve/ce/ve.ce.ProtectedNode.js
2 files changed, 29 insertions(+), 4 deletions(-)
Approvals:
Jforrester: 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 8166d37..5e5e0be 100644
--- a/modules/ve/ce/nodes/ve.ce.MWReferenceListNode.js
+++ b/modules/ve/ce/nodes/ve.ce.MWReferenceListNode.js
@@ -89,6 +89,14 @@
listGroup = this.model.getAttribute( 'listGroup' ),
nodes = internalList.getNodeGroup( listGroup );
+ // HACK: detach the children attached in the previous run
+ while ( this.attachedItems && this.attachedItems.length > 0 ) {
+ itemNode = this.attachedItems.pop();
+ itemNode.setLive( false );
+ itemNode.detach( this );
+ }
+ this.attachedItems = this.attachedItems || [];
+
this.$reflist.empty();
if ( nodes && nodes.keyOrder.length ) {
for ( i = 0, iLen = nodes.keyOrder.length; i < iLen; i++ ) {
@@ -111,6 +119,9 @@
itemNode = new ve.ce.InternalItemNode(
internalList.getItemNode(
keyNodes[0].getAttribute( 'listIndex' ) )
);
+ // HACK: ProtectedNode crashes when dealing with an
unattached node
+ this.attachedItems.push( itemNode );
+ itemNode.attach( this );
$li.append( $( '<span class="reference-text">' ).html(
itemNode.$.show() ) );
this.$reflist.append( $li );
}
diff --git a/modules/ve/ce/ve.ce.ProtectedNode.js
b/modules/ve/ce/ve.ce.ProtectedNode.js
index 081f22e..4f7f923 100644
--- a/modules/ve/ce/ve.ce.ProtectedNode.js
+++ b/modules/ve/ce/ve.ce.ProtectedNode.js
@@ -17,6 +17,7 @@
// Properties
this.$phantoms = $( [] );
this.$shields = $( [] );
+ this.isSetup = false;
// Events
this.connect( this, {
@@ -64,10 +65,16 @@
* @method
*/
ve.ce.ProtectedNode.prototype.onProtectedSetup = function () {
- var $shield,
+ var $shield, surfaceModel,
node = this,
- $shieldTemplate = this.constructor.static.$shieldTemplate,
- surfaceModel = this.getRoot().getSurface().getModel();
+ $shieldTemplate = this.constructor.static.$shieldTemplate;
+
+ if ( this.isSetup ) {
+ return;
+ }
+ this.isSetup = true;
+
+ surfaceModel = this.getRoot().getSurface().getModel();
// Events
this.$.on( 'mouseenter.ve-ce-protectedNode', ve.bind(
this.onProtectedMouseEnter, this ) );
@@ -96,7 +103,14 @@
* @method
*/
ve.ce.ProtectedNode.prototype.onProtectedTeardown = function () {
- var surfaceModel = this.getRoot().getSurface().getModel();
+ var surfaceModel;
+
+ if ( !this.isSetup ) {
+ return;
+ }
+ this.isSetup = false;
+
+ surfaceModel = this.getRoot().getSurface().getModel();
// Events
this.$.off( '.ve-ce-protectedNode' );
--
To view, visit https://gerrit.wikimedia.org/r/67212
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If00e75b939ccbdbaf681bbb6609fec54805bf9a0
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits