Fix content method
parent
edc7582de0
commit
1d7818582b
|
@ -15,7 +15,13 @@ pub trait SelectorBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn css_once<S: AsRef<str>>(&self, css_selector: S) -> Option<Selector> {
|
fn css_once<S: AsRef<str>>(&self, css_selector: S) -> Option<Selector> {
|
||||||
self.css(css_selector.as_ref()).pop()
|
let css_selector = css_selector.as_ref();
|
||||||
|
let mut nodes = self.css(css_selector);
|
||||||
|
if nodes.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(nodes.swap_remove(0))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn xpath<S: AsRef<str>>(&self, xpath: S) -> Vec<Selector> {
|
fn xpath<S: AsRef<str>>(&self, xpath: S) -> Vec<Selector> {
|
||||||
|
|
Loading…
Reference in New Issue