Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions shared/src/main/scala/scala/xml/NodeSeq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions shared/src/test/scala/scala/xml/XMLTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ class XMLTest {
assertEquals(expected, actual)
}

@UnitTest(expected=classOf[IllegalArgumentException])
def failEmptyStringChildren: Unit = {
<x/> \ ""
}

@UnitTest(expected=classOf[IllegalArgumentException])
def failEmptyStringDescendants: Unit = {
<x/> \\ ""
}

@UnitTest
def namespaces: Unit = {
val cuckoo = <cuckoo xmlns="http://cuckoo.com">
Expand Down