Skip to content

Commit 558264a

Browse files
author
Olaf Tomczak
committed
Fix for scala#183
1 parent 68e2187 commit 558264a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

shared/src/main/scala/scala/xml/Utility.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ object Utility extends AnyRef with parsing.TokenTests {
201201
minimizeTags: MinimizeMode.Value = MinimizeMode.Default): StringBuilder =
202202
{
203203
x match {
204-
case c: Comment if !stripComments => c buildString sb
204+
case c: Comment => if (!stripComments) c buildString sb; sb
205205
case s: SpecialNode => s buildString sb
206206
case g: Group =>
207207
for (c <- g.nodes) serialize(c, g.scope, sb, stripComments, decodeEntities, preserveWhitespace, minimizeTags); sb

shared/src/test/scala/scala/xml/UtilityTest.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,11 @@ class UtilityTest {
5656
assertEquals("<node><leaf/></node>", Utility.serialize(x, minimizeTags = MinimizeMode.Always).toString)
5757
}
5858

59+
@Test
60+
def issue183: Unit = {
61+
val x = <node><!-- comment --></node>
62+
assertEquals("<node></node>", Utility.serialize(x, stripComments = true).toString)
63+
assertEquals("<node><!-- comment --></node>", Utility.serialize(x, stripComments = false).toString)
64+
}
65+
5966
}

0 commit comments

Comments
 (0)