-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selector with comma support #8
Comments
Hmm, it's seems that comma is supported, though it's only works with |
Maybe the document should be updated...
pub type ElemIter<'b, 'a> = &'b mut (dyn Iterator<Item = ElementRef<'a>> + 'b);
pub trait FromHtml: Sized {
fn from_elements(select: ElemIter) -> Result<Self>;
fn from_html(html: &str) -> Result<Self> {
Self::from_elements(
&mut Html::parse_document(html).select(&Selector::parse(":root").unwrap()),
)
}
} While impl<T> FromHtml for Vec<T>
where
T: FromHtml,
{
fn from_elements(select: ElemIter) -> Result<Self> {
let mut ret = vec![];
for elem in select {
ret.push(vec![elem].into_iter().element()?)
}
Ok(ret)
}
} So, you can select only one element when straightly using |
It is an expected behaviour. |
I see, thanks! |
For now, it seems that comma in
#[html(selector = "...")]
is parsed but not supported. I think it should at least panic as non-supported operation, and of course it's better be implemented. Here's the sample snippet:The text was updated successfully, but these errors were encountered: