Fix content method

master
kirbylife 2024-09-29 00:51:22 -06:00
parent edc7582de0
commit 1d7818582b
1 changed files with 7 additions and 1 deletions

View File

@ -15,7 +15,13 @@ pub trait SelectorBase {
}
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> {