Skip to content

Commit caaab5f

Browse files
committed
Removed QueryAll and Query methods
1 parent 423ceea commit caaab5f

File tree

2 files changed

+0
-57
lines changed

2 files changed

+0
-57
lines changed

querying.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -100,36 +100,6 @@ func (node *Node) GetElementsById(idName string) NodeList {
100100
return nodeList
101101
}
102102

103-
// Query returns the first node that matches with the give query.
104-
func (node *Node) Query(query string) *Node {
105-
queryTokens := TokenizeQuery(query)
106-
107-
traverser := NewTraverser(node)
108-
var res *Node
109-
traverser.Walkthrough(func(node *Node) TraverseCondition {
110-
if matchQueryTokens(node, queryTokens) {
111-
res = node
112-
return StopWalkthrough
113-
}
114-
return ContinueWalkthrough
115-
})
116-
return res
117-
}
118-
119-
// QueryAll returns a NodeList containing nodes that matched with the given query.
120-
func (node *Node) QueryAll(query string) NodeList {
121-
nodeList := NewNodeList()
122-
queryTokens := TokenizeQuery(query)
123-
traverser := NewTraverser(node)
124-
125-
for node := range traverser.Walkthrough {
126-
if matchQueryTokens(node, queryTokens) {
127-
nodeList.Append(node)
128-
}
129-
}
130-
return nodeList
131-
}
132-
133103
/*
134104
QuerySearch tokenizes the query string and search for nodes that matches with the right most query token. After matching right most query it proceeds to match nodes parents nodes for left over tokens and then passed that node to (yield/range). QuerySearch search the whole node tree for matches unless yield get canceled or range iterator get cancel.
135105
*/

querying_test.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -166,33 +166,6 @@ func TestSelectorTokenizer(t *testing.T) {
166166
}
167167
}
168168

169-
func TestQuery(t *testing.T) {
170-
node, err := testFile4NodeTree()
171-
if err != nil {
172-
t.Fatal(err)
173-
return
174-
}
175-
imgEl := node.Query("img #idElement")
176-
imgSrc, _ := imgEl.GetAttribute("src")
177-
imgAlt, _ := imgEl.GetAttribute("alt")
178-
if imgSrc != "" || imgAlt != "" {
179-
t.Fatal("")
180-
}
181-
}
182-
183-
func TestQueryAll(t *testing.T) {
184-
node, err := testFile4NodeTree()
185-
if err != nil {
186-
t.Fatal(err)
187-
return
188-
}
189-
190-
nodeList := node.QueryAll("h2")
191-
if nodeList.Len() != 2 {
192-
t.Fatal("")
193-
}
194-
}
195-
196169
func TestQuerySelector(t *testing.T) {
197170
node, err := testFile4NodeTree()
198171
if err != nil {

0 commit comments

Comments
 (0)