summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-05-01 17:11:56 +0000
committerPaul Phillips <paulp@improving.org>2009-05-01 17:11:56 +0000
commit8cc51cc0dce7d86a4137eb636c4e3bed1b90cf13 (patch)
tree4187c272defe068a848bfbca6e1033e7f85ca85a /src
parenta020e82b2e46dd49da6bb2b8ec4f5aaded246907 (diff)
downloadscala-8cc51cc0dce7d86a4137eb636c4e3bed1b90cf13.tar.gz
scala-8cc51cc0dce7d86a4137eb636c4e3bed1b90cf13.tar.bz2
scala-8cc51cc0dce7d86a4137eb636c4e3bed1b90cf13.zip
Fix and test case for #1773.
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/xml/Node.scala22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/library/scala/xml/Node.scala b/src/library/scala/xml/Node.scala
index 197eed5ace..942220dc9e 100644
--- a/src/library/scala/xml/Node.scala
+++ b/src/library/scala/xml/Node.scala
@@ -129,13 +129,23 @@ abstract class Node extends NodeSeq {
* @return <code>true</code> if ..
*/
override def equals(x: Any): Boolean = x match {
- case g:Group => false
+ case g: Group => false
case that: Node =>
- ((that.prefix == this.prefix )
- &&(that.label == this.label )
- &&(that.attributes == this.attributes)
- && that.child.sameElements(this.child)) // sameElements
- case _ => false
+ this.prefix == that.prefix &&
+ this.label == that.label &&
+ this.attributes == that.attributes &&
+ equalChildren(that)
+ case _ => false
+ }
+
+ // children comparison has to be done carefully - see bug #1773.
+ // It would conceivably be a better idea for a scala block which
+ // generates the empty string not to generate a child rather than
+ // our having to filter it later, but that approach would be more
+ // delicate to implement.
+ private def equalChildren(that: Node) = {
+ def noEmpties(xs: Seq[Node]) = xs filter (_.toString() != "")
+ noEmpties(this.child) sameElements noEmpties(that.child)
}
/** <p>