jenkins-bot has submitted this change and it was merged.

Change subject: Converting an error image (red link) from block to inline does 
not lose its error state
......................................................................


Converting an error image (red link) from block to inline does not lose its 
error state

Bug: T101085
Change-Id: I521be8fbcbab27d712ec408ea7048dca2eaab198
---
M modules/ve-mw/dm/models/ve.dm.MWImageModel.js
1 file changed, 14 insertions(+), 1 deletion(-)

Approvals:
  Esanders: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ve-mw/dm/models/ve.dm.MWImageModel.js 
b/modules/ve-mw/dm/models/ve.dm.MWImageModel.js
index f9c7905..45a2061 100644
--- a/modules/ve-mw/dm/models/ve.dm.MWImageModel.js
+++ b/modules/ve-mw/dm/models/ve.dm.MWImageModel.js
@@ -43,6 +43,7 @@
        this.dir = null;
        this.lang = null;
        this.defaultDimensions = null;
+       this.changedImageSource = false;
 
        this.imageSrc = '';
        this.imageResourceName = '';
@@ -270,6 +271,8 @@
 ve.dm.MWImageModel.prototype.changeImageSource = function ( attrs, APIinfo ) {
        var imageModel = this;
 
+       this.changedImageSource = true;
+
        if ( attrs.mediaType ) {
                this.setMediaType( attrs.mediaType );
        }
@@ -449,7 +452,9 @@
        delete editAttributes.originalClasses;
        delete editAttributes.unrecognizedClasses;
        // Newly created images must have valid URLs, so remove the error 
attribute
-       delete editAttributes.isError;
+       if ( this.isChangedImageSource() ) {
+               delete editAttributes.isError;
+       }
 
        contentToInsert = [
                {
@@ -622,6 +627,14 @@
 };
 
 /**
+ * Check whether the image source is changed
+ * @return {boolean} changedImageSource flag on or off
+ */
+ve.dm.MWImageModel.prototype.isChangedImageSource = function () {
+       return this.changedImageSource;
+};
+
+/**
  * Check whether the image has floating alignment set
  * @param {string} [align] Optional. Alignment value to test against.
  * @return {boolean} hasAlignment flag on or off

-- 
To view, visit https://gerrit.wikimedia.org/r/218656
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I521be8fbcbab27d712ec408ea7048dca2eaab198
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: SuchetaG <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to