Skip to content
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

Add support for clss selection #13

Merged
merged 2 commits into from Jun 1, 2013
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Support css class selection

  • Loading branch information
ILyoan committed May 30, 2013
commit e854adf874a50fe0c8eeb9758ec926382be4ae8d
@@ -85,6 +85,7 @@ Callbacks used to query the implementation-specific DOM
*/
pub trait SelectHandler<N> {
fn with_node_name<R>(&self, node: &N, f: &fn(&str) -> R) -> R;
fn with_node_classes<R>(&self, node: &N, f: &fn(Option<&str>) -> R) -> R;
fn with_node_id<R>(&self, node: &N, f: &fn(Option<&str>) -> R) -> R;
fn named_parent_node(&self, node: &N, name: &str) -> Option<N>;
fn parent_node(&self, node: &N) -> Option<N>;
@@ -112,6 +113,21 @@ impl<N, H: SelectHandler<N>> n::s::CssSelectHandler<N> for SelectHandlerWrapper<
}
}

fn node_classes(&self, node: &N) -> Option<~[LwcString]> {
do self.inner_ref().with_node_classes(node) |node_classes_opt| {
do node_classes_opt.map |s| {
debug!("SelectHandlerWrapper::node_classes - classes: %?", *s);
let mut v = ~[];
for str::each_split_char(*s, ' ') |s| {
debug!("SelectHandlerWrapper::node_classes - class: %?", s);
if s != ~"" { v.push(lwcstr_from_rust_str(s)) }
}
debug!("SelectHandlerWrapper::classes: %?", v);
v
}
}
}

fn node_id(&self, node: &N) -> Option<LwcString> {
do self.inner_ref().with_node_id(node) |node_id_opt| {
node_id_opt.map(|s| lwcstr_from_rust_str(*s))
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.