Merge "Hack around exceptions thrown when closing the reference dialog"

This commit is contained in:
jenkins-bot 2013-06-07 00:13:10 +00:00 committed by Gerrit Code Review
commit 089cebd8e1
2 changed files with 29 additions and 4 deletions

View file

@ -89,6 +89,14 @@ ve.ce.MWReferenceListNode.prototype.update = function () {
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 @@ ve.ce.MWReferenceListNode.prototype.update = function () {
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 );
}

View file

@ -17,6 +17,7 @@ ve.ce.ProtectedNode = function VeCeProtectedNode() {
// Properties
this.$phantoms = $( [] );
this.$shields = $( [] );
this.isSetup = false;
// Events
this.connect( this, {
@ -64,10 +65,16 @@ ve.ce.ProtectedNode.static.$phantomTemplate = $( '<div>' )
* @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 @@ ve.ce.ProtectedNode.prototype.onProtectedSetup = function () {
* @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' );