From ca12b31c535d47eb5e7907d2c8a0f8b4a36350a9 Mon Sep 17 00:00:00 2001 From: seveibar Date: Wed, 28 Aug 2024 22:12:03 -0700 Subject: [PATCH] add support for pin being a port alias for selectors --- lib/utils/extend-aliases.ts | 12 ++++++++++++ lib/utils/selector-matching/index.ts | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 lib/utils/extend-aliases.ts diff --git a/lib/utils/extend-aliases.ts b/lib/utils/extend-aliases.ts new file mode 100644 index 0000000..ab9665f --- /dev/null +++ b/lib/utils/extend-aliases.ts @@ -0,0 +1,12 @@ +export const extendAliases = ( + aliases: string[], + additionalAliases: Record, +): string[] => { + return Array.from( + new Set( + aliases.flatMap((alias) => { + return [alias, ...(additionalAliases[alias] || [])] + }), + ), + ) +} diff --git a/lib/utils/selector-matching/index.ts b/lib/utils/selector-matching/index.ts index 97f6650..ecef3e5 100644 --- a/lib/utils/selector-matching/index.ts +++ b/lib/utils/selector-matching/index.ts @@ -33,7 +33,9 @@ export function isMatchingSelector( } // Split the selector into type and conditions - const [type, ...conditions] = selector.split(/(?=[#.[])/) + let [type, ...conditions] = selector.split(/(?=[#.[])/) + + if (type === "pin") type = "port" // Check if the component type matches if (