diff --git a/src/builtin/functions/selector.rs b/src/builtin/functions/selector.rs index 4015796..5773a80 100644 --- a/src/builtin/functions/selector.rs +++ b/src/builtin/functions/selector.rs @@ -9,7 +9,7 @@ use crate::{ value::Value, }; -fn is_superselector(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { +pub(crate) fn is_superselector(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { args.max_args(2)?; let parent_selector = args .get_err(0, "super")? @@ -21,7 +21,7 @@ fn is_superselector(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult) -> SassResult { +pub(crate) fn simple_selectors(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { args.max_args(1)?; // todo: Value::to_compound_selector let selector = args @@ -51,7 +51,7 @@ fn simple_selectors(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult) -> SassResult { +pub(crate) fn selector_parse(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { args.max_args(1)?; Ok(args .get_err(0, "selector")? @@ -59,7 +59,7 @@ fn selector_parse(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult) -> SassResult { +pub(crate) fn selector_nest(args: CallArgs, parser: &mut Parser<'_>) -> SassResult { let span = args.span(); let selectors = args.get_variadic()?; if selectors.is_empty() { @@ -80,7 +80,7 @@ fn selector_nest(args: CallArgs, parser: &mut Parser<'_>) -> SassResult { .into_value()) } -fn selector_append(args: CallArgs, parser: &mut Parser<'_>) -> SassResult { +pub(crate) fn selector_append(args: CallArgs, parser: &mut Parser<'_>) -> SassResult { let span = args.span(); let selectors = args.get_variadic()?; if selectors.is_empty() { @@ -138,7 +138,7 @@ fn selector_append(args: CallArgs, parser: &mut Parser<'_>) -> SassResult .into_value()) } -fn selector_extend(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { +pub(crate) fn selector_extend(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { args.max_args(3)?; let selector = args .get_err(0, "selector")? @@ -153,7 +153,7 @@ fn selector_extend(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult) -> SassResult { +pub(crate) fn selector_replace(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { args.max_args(3)?; let selector = args .get_err(0, "selector")? @@ -167,7 +167,7 @@ fn selector_replace(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult) -> SassResult { +pub(crate) fn selector_unify(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { args.max_args(2)?; let selector1 = args .get_err(0, "selector1")? diff --git a/src/builtin/mod.rs b/src/builtin/mod.rs index 56375bd..e1b3d41 100644 --- a/src/builtin/mod.rs +++ b/src/builtin/mod.rs @@ -1,4 +1,4 @@ mod functions; pub(crate) mod modules; -pub(crate) use functions::{math, meta, Builtin, GLOBAL_FUNCTIONS}; +pub(crate) use functions::{math, meta, selector, Builtin, GLOBAL_FUNCTIONS}; diff --git a/src/builtin/modules/selector.rs b/src/builtin/modules/selector.rs index 47d58dc..32a7860 100644 --- a/src/builtin/modules/selector.rs +++ b/src/builtin/modules/selector.rs @@ -1,5 +1,22 @@ use crate::{ - args::CallArgs, builtin::modules::Module, error::SassResult, parse::Parser, value::Value, + args::CallArgs, + builtin::modules::Module, + builtin::selector::{ + is_superselector, selector_append, selector_extend, selector_nest, selector_parse, + selector_replace, selector_unify, simple_selectors, + }, + error::SassResult, + parse::Parser, + value::Value, }; -pub(crate) fn declare(_f: &mut Module) {} +pub(crate) fn declare(f: &mut Module) { + f.insert_builtin("is-superselector", is_superselector); + f.insert_builtin("append", selector_append); + f.insert_builtin("extend", selector_extend); + f.insert_builtin("nest", selector_nest); + f.insert_builtin("parse", selector_parse); + f.insert_builtin("replace", selector_replace); + f.insert_builtin("unify", selector_unify); + f.insert_builtin("simple-selectors", simple_selectors); +}