Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanatkn committed Oct 4, 2024
1 parent b535854 commit 2af144b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/css_class_helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ const values: Array<[contents: string, expected: string[]]> = [
["classes = ['a'", []],
['classes = ["a",,"b",,,"c",]', ['a', 'b', 'c']],
// nested arrays
['classes = [["a", "b"], "c", ["d"]]', ['c']], // TODO BLOCK FAILING
['classes = ["a", ["b", "c"], "d"]', ['a', 'd']], // TODO BLOCK FAILING
['classes = [["a", "b"], "c", ["d"]]', []], // TODO @many ideally fix instead of bailing, but maybe we need a real JS parser?
['classes = ["a", ["b", "c"], "d"]', []], // TODO @many ideally fix instead of bailing, but maybe we need a real JS parser?
// arrays in component prop
['<Component classes={["a", "b", "c"]} />', ['a', 'b', 'c']],
['<Component class={["a", "b", "c"]} />', ['a', 'b', 'c']],
Expand Down
1 change: 1 addition & 0 deletions src/lib/css_class_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const CSS_CLASS_EXTRACTORS: Css_Extractor[] = [
matcher: /(?<!['"`])class(?:es)?\s*[=:]\{?\s*\[([\s\S]*?)\]/g,
mapper: (matched: RegExpExecArray): string[] => {
const content = matched[1];
if (content.includes('[')) return []; // TODO @many ideally fix instead of bailing, but maybe we need a real JS parser?
const items = content.split(',').map((item) => item.trim());

return items
Expand Down

0 comments on commit 2af144b

Please sign in to comment.