Skip to content

Commit

Permalink
Merge pull request #279 from doong-jo/fix-duplicated-style-priority
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredh159 authored Feb 26, 2024
2 parents 63af025 + d1c7470 commit 8db97f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/__tests__/tw.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,9 @@ describe(`tw`, () => {
expect(tw.style(`w-1 lg:w-3`)).toEqual({ width: 12 });
expect(tw.style(`w-1 md:w-2 lg:w-3`)).toEqual({ width: 12 });
});

test(`duplicated style priority`, () => {
expect(tw`bg-white bg-black`).toEqual({ backgroundColor: `#000` });
expect(tw`bg-white bg-black bg-white`).toEqual({ backgroundColor: `#fff` });
});
});
2 changes: 1 addition & 1 deletion src/parse-inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ function split(str: string): string[] {
}

function unique(className: string, index: number, classes: string[]): boolean {
return classes.indexOf(className) === index;
return classes.lastIndexOf(className) === index;
}

0 comments on commit 8db97f2

Please sign in to comment.