use super::legacy;
use super::types::{Adapter, CompiledQuery, Options};
use crate::{css_select::compile::compile_token as compile_token_impl, dom::element::HTMLElement};
pub fn select_all<'a>(selector: &str, root: &'a HTMLElement) -> Vec<&'a HTMLElement> {
legacy::query_selector_all(root, selector)
}
pub fn select_one<'a>(selector: &str, root: &'a HTMLElement) -> Option<&'a HTMLElement> {
select_all(selector, root).into_iter().next()
}
pub fn is<'a>(elem: &'a HTMLElement, selector: &str, root: &'a HTMLElement) -> bool {
let ptr = elem as *const HTMLElement;
select_all(selector, root)
.into_iter()
.any(|e| std::ptr::eq(e as *const HTMLElement, ptr))
}
pub fn prepare_context<'a>(root: &'a HTMLElement) -> Vec<&'a HTMLElement> {
vec![root]
}
pub fn compile<'a, A: Adapter>(
selector: &str,
options: &Options<A>,
root: &'a HTMLElement,
) -> CompiledQuery<'a, A> {
compile_token_impl::<A>(selector, options, root)
}
pub fn compile_token<'a, A: Adapter>(
selector: &str,
options: &Options<A>,
root: &'a HTMLElement,
) -> CompiledQuery<'a, A> {
compile_token_impl::<A>(selector, options, root)
}
pub fn compile_unsafe<'a, A: Adapter>(
selector: &str,
options: &Options<A>,
root: &'a HTMLElement,
) -> CompiledQuery<'a, A> {
compile_token_impl::<A>(selector, options, root)
}
pub fn compile_experimental<'a, A: Adapter + 'a>(
selector: &str,
_options: &Options<A>,
adapter: &'a A,
) -> CompiledQuery<'a, A> {
crate::css_select::compile::compile_internal_new::<A>(selector, adapter)
}