pqina / vue-filepond

🔌 A handy FilePond adapter component for Vue
https://pqina.nl/filepond
MIT License
1.92k stars 128 forks source link

[Bug] __unset__ props Vue Filepond v7 #240

Closed Tofandel closed 2 years ago

Tofandel commented 2 years ago

Is there an existing issue for this?

Have you updated Vue FilePond, FilePond, and all plugins?

Describe the bug

__unset__ default prop value is being displayed in HTML attributes, which wasn't the case in v6 (vue 2)

image

This is also a big problem if using the validate-file-type plugin and not declaring an accepted type, all files will be rejected instead of all accepted image

Reproduction

https://codesandbox.io/s/vue-filepond-live-demo-forked-7fpymj?file=/src/main.js

Environment

- Vue version: 3
Tofandel commented 2 years ago

As I'm not exactly sure why __unset__ has been added as default value instead of just leaving it undefined, I made 2 PRs, one keeping it, and one removing it entirely

rikschennink commented 2 years ago

It's been a while but if I remember correctly it's set to __unset__ because undefined is also a value that can be passed to props and I needed a way to know if a prop was passed.

Tofandel commented 2 years ago

Do you have an example or use case of when would undefined be passed to a prop?

Because with a quick test, a prop without a type passed like a boolean prop (eg: <Filepond allow-multiple>) will be an empty string and not undefined so that seems like something that's just not needed and instead causes problems

The only way to pass undefined is <Filepond :allow-multiple="undefined"> but then this should be respected, because it's a way to unset a prop in vue <Filepond :allow-multiple="multiple ? true : undefined"> (or passing down a prop with no default value)

In general, js is gifting us with both undefined and null in comparison with other languages and so undefined is used to unset and an unset value can have a fallback to default, as opposed to null which is to set no value which shouldn't fallback to default. So adding an intermediate string for this is a wrong usage of js

sammyaxe commented 2 years ago

having capture="unset" prevents safari on iOS from prompting image gallery, files or camera select and defaults it to capture, there should be no capture tag by default.

rikschennink commented 2 years ago

Pushed release 7.0.3 which should fix the issue.