Skip to content

Commit abb3fe6

Browse files
olafosOlaf Tomczak
authored and
Olaf Tomczak
committed
Fixes regression bug causing stripComments parameter of Utility.serialize to be effectively ignored (scala#183)
1 parent 68e2187 commit abb3fe6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Diff for: shared/src/main/scala/scala/xml/Utility.scala

+1-1
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

Diff for: shared/src/test/scala/scala/xml/UtilityTest.scala

+7
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)