Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow merge method to accept null as argument to prevent exception #12

Merged
merged 4 commits into from
Aug 7, 2024

Conversation

ampedweb
Copy link
Contributor

@ampedweb ampedweb commented Aug 6, 2024

This was something I came across while using this filter in conjunction with the Symfony UX Twig Components
https://symfony.com/bundles/ux-twig-component/current/index.html#cva-and-tailwind-css

I found that if I used the filter like this attributes.render('class')|tailwind_merge and render('class') ended up returning null it results in a crash.

You can work around this by using null coalesce like attributes.render('class') ?? ''|tailwind_merge but this feels a bit cumbersome when using it in quite a few places throughout a component.

It feels like simply allowing null as an accepted argument type and letting it return an empty string is sensible rather than throwing a type exception.

Would be interested to know your thoughts on this. 🙂 Thanks!

@ker0x
Copy link
Member

ker0x commented Aug 7, 2024

Not much to say, I'm ok with those changes 👌 ! Thanks

@ker0x ker0x merged commit a3cb864 into tales-from-a-dev:main Aug 7, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants