Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/136286

Change subject: Fix page freeze on table copy and align
......................................................................

Fix page freeze on table copy and align

The alignment correction logic uses min-height css property and it is
undefined for table elements.
Added a safegurad for alignment correction by pixel accuracy algorithm
not entering to an infinite loop state.

Bug: 64542
Change-Id: I6d625caa4c714d08a41bc122d7fcff9085e1710d
---
M modules/translation/ext.cx.translation.js
1 file changed, 12 insertions(+), 2 deletions(-)


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

diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index eb98235..a9e8085 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -284,10 +284,16 @@
         * so that they will appear top aligned.
         */
        function keepAlignment() {
-               var $sourceSection, sectionHeight, sourceSectionHeight, 
$section;
+               var $sourceSection, sectionHeight, sourceSectionHeight, 
$section, steps = 0;
 
                /*jshint validthis:true */
                $section = $( this );
+
+               if ( $section.prop( 'tagName' ) === 'TABLE' ) {
+                       // 'min-height' is undefined for table elements
+                       return true;
+               }
+
                $sourceSection = $( '#' + $section.data( 'source' ) );
                $sourceSection.css( 'min-height', '' );
 
@@ -304,11 +310,15 @@
                        // Experiments shows a few pixels difference
                        // Here we do it by 10px steps till we reach equal 
height.
                        while ( sectionHeight !== sourceSectionHeight ) {
-                               sectionHeight = sectionHeight = sectionHeight + 
10;
+                               sectionHeight = sectionHeight + 10;
                                $sourceSection.css( 'min-height', sectionHeight 
);
                                $section.css( 'min-height', sectionHeight );
                                sectionHeight = $section.height();
                                sourceSectionHeight = $sourceSection.height();
+                               if ( steps++ === 1000 ) {
+                                       mw.log( 'Alignment attempt is not 
succeeding. Aborting.' );
+                                       break;
+                               }
                        }
                }
        }

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

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

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

Reply via email to