File tree Expand file tree Collapse file tree
main/java/ch/digitalfondue/jfiveparse
test/java/ch/digitalfondue/jfiveparse Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -160,12 +160,12 @@ public Selector element(String name) {
160160 }
161161
162162 /**
163- * Universal selector "*". It matches any node.
163+ * Universal selector "*". It matches any _element_ node.
164164 *
165165 * @return
166166 */
167167 public Selector universal () {
168- matchers .add (n -> true );
168+ matchers .add (n -> n . getNodeType () == Node . ELEMENT_NODE );
169169 return this ;
170170 }
171171
Original file line number Diff line number Diff line change @@ -50,6 +50,15 @@ void universalTest() {
5050 assertEquals (doc .getElementsByTagName ("body" ).get (0 ).getChildNodes ().get (1 ).getChildNodes ().get (0 ), universal .get (0 ));
5151 }
5252
53+ @ Test
54+ void universalWithSpaces () {
55+ Document doc = parser .parse (" <div> </div> <div id=myid> <span> <i> </i> </span> </div> <div> </div> " );
56+ // div > *
57+ var universal = doc .getElementsByTagName ("body" ).get (0 ).getAllNodesMatching (Selector .select ().element ("div" ).withChild ().universal ().toMatcher ());
58+ assertEquals (1 , universal .size ());
59+ assertEquals ("span" , universal .get (0 ).getNodeName ());
60+ }
61+
5362 @ Test
5463 void firstElementTest () {
5564 Document doc = parser .parse ("text<div></div><div id=myid></div><div></div>" );
You can’t perform that action at this time.
0 commit comments