diff --git a/shared/src/main/scala/scala/xml/NodeSeq.scala b/shared/src/main/scala/scala/xml/NodeSeq.scala
index fe071488f..21de379bb 100644
--- a/shared/src/main/scala/scala/xml/NodeSeq.scala
+++ b/shared/src/main/scala/scala/xml/NodeSeq.scala
@@ -140,8 +140,10 @@ abstract class NodeSeq extends AbstractSeq[Node] with immutable.Seq[Node] with S
* The document order is preserved.
*/
def \\(that: String): NodeSeq = {
+ def fail = throw new IllegalArgumentException(that)
def filt(cond: (Node) => Boolean) = this flatMap (_.descendant_or_self) filter cond
that match {
+ case "" => fail
case "_" => filt(!_.isAtom)
case _ if that(0) == '@' => filt(!_.isAtom) flatMap (_ \ that)
case _ => filt(x => !x.isAtom && x.label == that)
diff --git a/shared/src/test/scala/scala/xml/XMLTest.scala b/shared/src/test/scala/scala/xml/XMLTest.scala
index 998b06dcd..93e443119 100644
--- a/shared/src/test/scala/scala/xml/XMLTest.scala
+++ b/shared/src/test/scala/scala/xml/XMLTest.scala
@@ -145,6 +145,16 @@ class XMLTest {
assertEquals(expected, actual)
}
+ @UnitTest(expected=classOf[IllegalArgumentException])
+ def failEmptyStringChildren: Unit = {
+ \ ""
+ }
+
+ @UnitTest(expected=classOf[IllegalArgumentException])
+ def failEmptyStringDescendants: Unit = {
+ \\ ""
+ }
+
@UnitTest
def namespaces: Unit = {
val cuckoo =