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

✨ Bring back nullish values support via option #95

Open
1 task
jd-solanki opened this issue May 26, 2023 · 2 comments
Open
1 task

✨ Bring back nullish values support via option #95

jd-solanki opened this issue May 26, 2023 · 2 comments

Comments

@jd-solanki
Copy link

Describe the feature

Hi πŸ‘‹πŸ»

I'm author of Anu UI lib. I'm using defu and it's doing an amazing job until I found that it skips nullish values undefined & null 😞

Why?

If we want to allow explicitly set null or undefined for property it's not possible ATM.

I'm trying to implement global prop defaults via vue plugin options for my lib. If user wants to disable some prop, the user can pass undefined in the plugin option but unfortunately defu skips that and uses default from component props definition 😬

Proposed Solution

We can keep the defu's default behavior and introduce option to consider nullish value while merging like below:

defu(obj, defaults, { skipNullish: false })

Additional context

I guess this was already implemented before and we removed this in this PR.

I can use mentioned alternatives but those aren't from unjs family and are outdated (might be vulnerable) which makes defu one and only choice.

Additional information

  • Would you be willing to help implement this feature?
@jd-solanki
Copy link
Author

jd-solanki commented Jan 23, 2024

Hi,

I'm rewriting Anu for v1 and trying to remove external libs as much as possible. If defu bring back this feature via custom merger then this will allow me to remove deepmerge-ts lib.

There are few upvotes as well that might change your mind to reintroduce this feature.


I tried creating customDefu but I defu isn't passing undefined/null values πŸ€·πŸ»β€β™‚οΈ

@Yizack
Copy link

Yizack commented Jun 28, 2024

Hi, sometimes while using defu I wish it could be able to not skip null values ​​as well, hope this is reconsidered 😊

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

No branches or pull requests

2 participants