Skip to content

Commit 668dbd8

Browse files
committed
fix: fix useDivideAttrs not generating keys for all divisions even if empty
1 parent 734a35a commit 668dbd8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/composables/useDivideAttrs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import { keys } from "@alanscodelog/utils"
2525
*/
2626
export const useDivideAttrs = <T extends readonly string[]>(attrs: Record<string, any>, divisionKeys: T): Record<`${T[number]}Attrs` | "$attrs", any> => {
2727
const res: any = { $attrs: {} }
28-
for (const attrKey of keys(attrs)) {
29-
for (const key of divisionKeys) {
30-
res[`${key}Attrs`] = res[`${key}Attrs`] ?? {}
28+
for (const key of divisionKeys) {
29+
res[`${key}Attrs`] = {}
30+
for (const attrKey of keys(attrs)) {
3131
if (attrKey.startsWith(`${key}-`)) {
3232
res[`${key}Attrs`][attrKey.slice(key.length + 1)] = attrs[attrKey]
3333
} else if (attrKey.startsWith(key)) {

0 commit comments

Comments
 (0)