handle non-list to nth()

This commit is contained in:
ConnorSkees 2020-03-20 12:36:31 -04:00
parent 284bc8ea6d
commit 5ce2515fb6
2 changed files with 6 additions and 1 deletions

View File

@ -25,7 +25,7 @@ pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
max_args!(args, 2); max_args!(args, 2);
let list = match arg!(args, 0, "list") { let list = match arg!(args, 0, "list") {
Value::List(v, _) => v, Value::List(v, _) => v,
_ => return Err("Missing argument $list.".into()), v => vec![v],
}; };
let n = match arg!(args, 1, "n") { let n = match arg!(args, 1, "n") {
Value::Dimension(num, _) => num, Value::Dimension(num, _) => num,

View File

@ -33,6 +33,11 @@ test!(
"a {\n color: nth((a, b, c), 3);\n}\n", "a {\n color: nth((a, b, c), 3);\n}\n",
"a {\n color: c;\n}\n" "a {\n color: c;\n}\n"
); );
test!(
nth_non_list,
"a {\n color: nth(foo, 1);\n}\n",
"a {\n color: foo;\n}\n"
);
test!( test!(
list_separator_space_separated, list_separator_space_separated,
"a {\n color: list-separator(a b c);\n}\n", "a {\n color: list-separator(a b c);\n}\n",