MWMediaDialog: Remove redundant check of this.imageModel existence

The fact it has to exist for the two previous statements to
not fatal is a bit of a clue. I assume this made sense at
some point in the past.

Change-Id: Ic9c04395408301f514ff7e9a224b8e2c30d64896
This commit is contained in:
Ed Sanders 2015-08-02 18:42:07 +01:00 committed by Jforrester
parent 022fa98856
commit 322d1f54c6

View file

@ -1244,33 +1244,30 @@ ve.ui.MWMediaDialog.prototype.getActionProcess = function ( action ) {
this.captionTarget.getSurface().getModel().getDocument()
);
// TODO: Simplify this condition
if ( this.imageModel ) {
if (
// There was an initial node
this.selectedNode &&
// And we didn't change the image type block/inline or vise versa
this.selectedNode.type === this.imageModel.getImageNodeType() &&
// And we didn't change the image itself
this.selectedNode.getAttribute( 'src' ) ===
this.imageModel.getImageSource()
) {
// We only need to update the attributes of the current node
this.imageModel.updateImageNode( this.selectedNode, surfaceModel );
} else {
// Replacing an image or inserting a brand new one
if (
// There was an initial node
this.selectedNode &&
// And we didn't change the image type block/inline or vise versa
this.selectedNode.type === this.imageModel.getImageNodeType() &&
// And we didn't change the image itself
this.selectedNode.getAttribute( 'src' ) ===
this.imageModel.getImageSource()
) {
// We only need to update the attributes of the current node
this.imageModel.updateImageNode( this.selectedNode, surfaceModel );
} else {
// Replacing an image or inserting a brand new one
// If there was a previous node, remove it first
if ( this.selectedNode ) {
// Remove the old image
this.fragment = this.getFragment().clone(
new ve.dm.LinearSelection( this.fragment.getDocument(), this.selectedNode.getOuterRange() )
);
this.fragment.removeContent();
}
// Insert the new image
this.fragment = this.imageModel.insertImageNode( this.getFragment() );
// If there was a previous node, remove it first
if ( this.selectedNode ) {
// Remove the old image
this.fragment = this.getFragment().clone(
new ve.dm.LinearSelection( this.fragment.getDocument(), this.selectedNode.getOuterRange() )
);
this.fragment.removeContent();
}
// Insert the new image
this.fragment = this.imageModel.insertImageNode( this.getFragment() );
}
this.close( { action: action } );