From 9a2df97dc524ed7fa9f4077e538104d91c7f4ffe Mon Sep 17 00:00:00 2001 From: Elijah Mooring Date: Thu, 4 Aug 2022 14:57:12 -0500 Subject: [PATCH] fix: split classes on all whitespace --- alias.test.ts | 14 ++++++++++++++ alias.ts | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/alias.test.ts b/alias.test.ts index b14f7ec..48f79a2 100644 --- a/alias.test.ts +++ b/alias.test.ts @@ -13,6 +13,20 @@ Deno.test({ }, }) +Deno.test({ + name: '[alias] should substitute classes with newlines', + fn() { + const map = aliasMap([alias('alias-name', 'base-styles to-apply')]) + + const input = ` + alias-name + alias-name-foo-bar alias-name-foo-bar-baz` + const output = 'base-styles to-apply base-styles to-apply base-styles to-apply' + + assertEquals(lookup(map, input), output) + }, +}) + Deno.test({ name: '[alias] should apply variations', fn() { diff --git a/alias.ts b/alias.ts index d8e15da..24763d8 100644 --- a/alias.ts +++ b/alias.ts @@ -153,7 +153,7 @@ export function alias(name: string, params: AliasParams | string | AliasFn): Ali } function splitClasses(classes: string) { - return classes.split(/ +/) + return classes.trim().split(/\s+/) } function joinClassSections(sections: string[]) {