Skip to content

Commit

Permalink
fix: revert behaviour of twMerge - fixes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
gehrisandro committed Aug 10, 2023
1 parent e59e6d9 commit 2d6d974
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## v0.2.1 (2023-08-10)
### Fixed
- Revert the behaviour of `twMerge`

## v0.2.0 (2023-08-09)
### Added
- Add `twMergeFor` and `withoutTwMergeClasses` on the ComponentAttributesBag

## v0.1.0 (2023-06-16)
### Fixed
- Remove DeferrableProvider - fixes ([#2](https://github.com/gehrisandro/tailwind-merge-laravel/issues/2))
Expand Down
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
parameters:
ignoreErrors:
-
message: "#^Call to an undefined method Illuminate\\\\View\\\\ComponentAttributeBag\\:\\:twMergeFor\\(\\)\\.$#"
message: "#^Cannot call method merge\\(\\) on mixed\\.$#"
count: 1
path: src/TailwindMergeServiceProvider.php

Expand Down
4 changes: 3 additions & 1 deletion src/TailwindMergeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ protected function registerAttributesBagMacros(): void
{
ComponentAttributeBag::macro('twMerge', function (...$args): ComponentAttributeBag {
/** @var ComponentAttributeBag $this */
return $this->twMergeFor('', ...$args);
$this->offsetSet('class', resolve(TailwindMergeContract::class)->merge($args, ($this->get('class', ''))));

return $this;
});

ComponentAttributeBag::macro('twMergeFor', function (string $for, ...$args): ComponentAttributeBag {
Expand Down

0 comments on commit 2d6d974

Please sign in to comment.