Santhosh has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/393556 )

Change subject: Prevent js error in template adaptation
......................................................................

Prevent js error in template adaptation

The root cause for not having a visible fragment for template in
target langauge is unknow and issue was not able to reproducable
for me. This patch just prevents further damages. Not really nice
though.

Bug: T176237
Change-Id: I9b23f893944e46e21f4fa531aae5894830911669
---
M modules/tools/ext.cx.tools.template.js
1 file changed, 9 insertions(+), 4 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/56/393556/1

diff --git a/modules/tools/ext.cx.tools.template.js 
b/modules/tools/ext.cx.tools.template.js
index 403bd87..50d77c4 100644
--- a/modules/tools/ext.cx.tools.template.js
+++ b/modules/tools/ext.cx.tools.template.js
@@ -962,7 +962,6 @@
                var self = this;
 
                this.targetTemplate.$template.first().cxoverlay( {
-                       fullscreen: false,
                        showLoading: true
                } );
                return this.targetTemplate.getUpdatedTemplate().then( function 
( $newTemplate ) {
@@ -978,9 +977,16 @@
         * @param {string} state The new state of the template.
         */
        TemplateTool.prototype.replaceTargetTemplate = function ( $newTemplate, 
state ) {
-               var sourceId, $new;
+               var sourceId, $new, $visibleFragment;
 
-               sourceId = this.sourceTemplate.getFirstVisibleFragment().prop( 
'id' );
+               $visibleFragment = 
this.sourceTemplate.getFirstVisibleFragment();
+               if ( !$visibleFragment ) {
+                       // This should not happen. But prevent js error if it 
happens. See T176237
+                       mw.error( '[CX] Error: No visible fragment for template 
for ' + this.sourceTemplate.title );
+                       // Stopping here means no template editor for this 
particular template.
+                       return;
+               }
+               sourceId = $visibleFragment.prop( 'id' );
                $new = $newTemplate
                        .clone()
                        .attr( {
@@ -1147,7 +1153,6 @@
 
                // Not a processed template. Proceed with attempt to adapt.
                $targetTemplate.first().cxoverlay( {
-                       fullscreen: false,
                        showLoading: true
                } );
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9b23f893944e46e21f4fa531aae5894830911669
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to