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

Change subject: Bug 48760: Remove br tags from diffs
......................................................................


Bug 48760: Remove br tags from diffs

Change-Id: Ia2185b655c1d84ef29781e8702290a719ebe8865
---
M javascripts/specials/mobilediff.js
M tests/javascripts/specials/test_mobilediff.js
2 files changed, 31 insertions(+), 16 deletions(-)

Approvals:
  JGonera: Verified; Looks good to me, approved
  awjrichards: Verified; Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/javascripts/specials/mobilediff.js 
b/javascripts/specials/mobilediff.js
index 9295cee..b516b10 100644
--- a/javascripts/specials/mobilediff.js
+++ b/javascripts/specials/mobilediff.js
@@ -5,12 +5,23 @@
                        diff;
 
                $diffclone.find( 'del,ins' ).each( function() {
-                       if ( this.tagName === 'DEL' ) {
-                               before += $( this ).text() + '<br>';
-                       } else {
-                               after += $( this ).text() + '<br>';
+                       var text = $( this ).text();
+                       if ( text ) {
+                               if ( this.tagName === 'DEL' ) {
+                                       before += text + '\n';
+                               } else {
+                                       after += $( this ).text() + '\n';
+                               }
                        }
                } );
+               // remove last 2 new lines
+               if ( before ) {
+                       before = before.substr( 0, before.length - 1 );
+               }
+               if ( after ) {
+                       after = after.substr( 0, after.length - 1 );
+               }
+
                $diff.empty().addClass( 'prettyDiff' );
 
                diff = JsDiff.diffWords( before, after );
@@ -23,13 +34,13 @@
                        } else {
                                tag = '<span>';
                        }
-                       vals = change.value.split( '<br>' );
-                       vals.forEach( function( val ) {
+                       vals = change.value.split( '\n' );
+                       vals.forEach( function( val, i ) {
                                if ( val ) {
                                        $( tag ).text( val ).appendTo( $diff );
-                                       if ( vals.length > 1 ) {
-                                               $( '<br>' ).appendTo( $diff );
-                                       }
+                               }
+                               if ( i < vals.length - 1 ) {
+                                       $( '<br>' ).appendTo( $diff );
                                }
                        } );
                } );
diff --git a/tests/javascripts/specials/test_mobilediff.js 
b/tests/javascripts/specials/test_mobilediff.js
index 3451a04..aba7931 100644
--- a/tests/javascripts/specials/test_mobilediff.js
+++ b/tests/javascripts/specials/test_mobilediff.js
@@ -6,31 +6,35 @@
 
 QUnit.test( 'makePrettyDiff', function() {
        var testCases = [
-               [ $( '<div><del>foo</del></div>' ), '<del>foo</del><br>' ],
+               [ $( '<div><del>foo</del></div>' ), '<del>foo</del>' ],
                [
                        $( '<div><del>Remove the one please</del><ins>Remove 
the please</ins></div>' ),
-                       '<span>Remove the </span><del>one 
</del><span>please</span><br>'
+                       '<span>Remove the </span><del>one 
</del><span>please</span>'
+               ],
+               [
+                       $( '<div><del>Here we go.</del><ins>Here we go. 
Ha!</ins></div>' ),
+                       '<span>Here we go.</span><ins> Ha!</ins>'
                ],
                [
                        $( '<div><ins>Added text</ins><ins>Blah, bloh, foo and 
bleh [[linkchange]]</ins><del>Blah, bloh and bleh [[link]]</del><ins>more 
text</ins></div>' ),
-                       '<ins>Added text</ins><br><span>Blah, 
bloh</span><ins>,</ins><span> </span><ins>foo </ins><span>and bleh 
[[</span><ins>linkchange</ins><del>link</del><span>]]</span><br><ins>more 
text</ins><br>'
+                       '<ins>Added text</ins><br><span>Blah, 
bloh</span><ins>,</ins><span> </span><ins>foo </ins><span>and bleh 
[[</span><ins>linkchange</ins><del>link</del><span>]]</span><br><ins>more 
text</ins>'
                ],
                [
                        $( '<div id="mw-mf-minidiff"><del>According to popular 
legend, the \'\'\'Shanghai Tunnels,\'\'\' less commonly known as the 
\'\'\'Portland Underground,\'\'\' are supposedly a group of passages running 
underneath [[Old Town Chinatown, Portland, Oregon|Old Town/Chinatown]] down to 
the central downtown section of [[Portland, Oregon|Portland]], [[Oregon]], 
[[United States]]. The tunnels connected the [[basement]]s of many downtown 
[[hotel]]s and [[bar (establishment)|bar]]s to the waterfront of the 
[[Willamette River]]. They were built to move goods from the ships docked on 
the Willamette to the basement storage areas, which allowed businesses to avoid 
streetcar and train traffic on the streets when delivering their 
goods.{{fact|date=March 2012}}</del><ins>According to popular legend, the 
\'\'\'Shanghai Tunnels,\'\'\' less commonly known as the \'\'\'Portland 
Underground,\'\'\' are a group of passages running underneath [[Old Town 
Chinatown, Portland, Oregon|Old Town/Chinatown]] down to the central downtown 
section of [[Portland, Oregon|Portland]], [[Oregon]], [[United States]]. The 
tunnels connected the [[basement]]s of many downtown [[hotel]]s and [[bar 
(establishment)|bar]]s to the waterfront of the [[Willamette River]]. They were 
built to move goods from the ships docked on the Willamette to the basement 
storage areas, which allowed businesses to avoid streetcar and train traffic on 
the streets when delivering their goods.{{fact|date=March 2012}}</ins></div>' ),
-                       '<span>According to popular legend, the \'\'\'Shanghai 
Tunnels,\'\'\' less commonly known as the \'\'\'Portland Underground,\'\'\' are 
</span><del>supposedly </del><span>a group of passages running underneath [[Old 
Town Chinatown, Portland, Oregon|Old Town/Chinatown]] down to the central 
downtown section of [[Portland, Oregon|Portland]], [[Oregon]], [[United 
States]]. The tunnels connected the [[basement]]s of many downtown [[hotel]]s 
and [[bar (establishment)|bar]]s to the waterfront of the [[Willamette River]]. 
They were built to move goods from the ships docked on the Willamette to the 
basement storage areas, which allowed businesses to avoid streetcar and train 
traffic on the streets when delivering their goods.{{fact|date=March 
2012}}</span><br>'
+                       '<span>According to popular legend, the \'\'\'Shanghai 
Tunnels,\'\'\' less commonly known as the \'\'\'Portland Underground,\'\'\' are 
</span><del>supposedly </del><span>a group of passages running underneath [[Old 
Town Chinatown, Portland, Oregon|Old Town/Chinatown]] down to the central 
downtown section of [[Portland, Oregon|Portland]], [[Oregon]], [[United 
States]]. The tunnels connected the [[basement]]s of many downtown [[hotel]]s 
and [[bar (establishment)|bar]]s to the waterfront of the [[Willamette River]]. 
They were built to move goods from the ships docked on the Willamette to the 
basement storage areas, which allowed businesses to avoid streetcar and train 
traffic on the streets when delivering their goods.{{fact|date=March 
2012}}</span>'
                ],
                [
                        $( '<div id="mw-mf-minidiff"><del>A total of 40 
consulates-generals and 24 honorary consulates have offices in the San 
Francisco Bay Area.</del><ins>A total of 41 consulates-generals and 24 honorary 
consulates have offices in the San Francisco Bay Area.</ins></div>' ),
-                       '<span>A total of 
</span><ins>41</ins><del>40</del><span> consulates-generals and 24 honorary 
consulates have offices in the San Francisco Bay Area.</span><br>'
+                       '<span>A total of 
</span><ins>41</ins><del>40</del><span> consulates-generals and 24 honorary 
consulates have offices in the San Francisco Bay Area.</span>'
                ],
                [
                        $( '<div id="mw-mf-minidiff"><del></del><del>== 
Fliberty gibbit ==</del><del>Foobar!</del></div>' ),
-                       '<del>== Fliberty gibbit 
==</del><br><del>Foobar!</del><br>'
+                       '<del>== Fliberty gibbit ==</del><br><del>Foobar!</del>'
                ],
                [
                        // no deletions
                        $( '<div id="mw-mf-minidiff"><ins></ins><ins>French duo 
Daft Punk weren\'t named in the initial announcement, but added the festival to 
a list of shows on its official Vevo page on March 27. &lt;ref&gt;{{cite news| 
url= 
http://www.3news.co.nz/Daft-Punk-website-shows-Coachella-date/tabid/418/articleID/292127/Default.aspx|work=3
 News NZ |title= Daft Punk website shows Coachella date| date=March 28, 
2013}}&lt;/ref&gt;</ins></div></div>' ),
-                       '<ins>French duo Daft Punk weren\'t named in the 
initial announcement, but added the festival to a list of shows on its official 
Vevo page on March 27. &lt;ref&gt;{{cite news| url= 
http://www.3news.co.nz/Daft-Punk-website-shows-Coachella-date/tabid/418/articleID/292127/Default.aspx|work=3
 News NZ |title= Daft Punk website shows Coachella date| date=March 28, 
2013}}&lt;/ref&gt;</ins><br>'
+                       '<ins>French duo Daft Punk weren\'t named in the 
initial announcement, but added the festival to a list of shows on its official 
Vevo page on March 27. &lt;ref&gt;{{cite news| url= 
http://www.3news.co.nz/Daft-Punk-website-shows-Coachella-date/tabid/418/articleID/292127/Default.aspx|work=3
 News NZ |title= Daft Punk website shows Coachella date| date=March 28, 
2013}}&lt;/ref&gt;</ins>'
                ]
        ];
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia2185b655c1d84ef29781e8702290a719ebe8865
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: awjrichards <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to