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

Boolean props conversions don't work #843

Closed
jods4 opened this issue Mar 15, 2020 · 3 comments · Fixed by #844
Closed

Boolean props conversions don't work #843

jods4 opened this issue Mar 15, 2020 · 3 comments · Fixed by #844

Comments

@jods4
Copy link
Contributor

jods4 commented Mar 15, 2020

Version

3.0.0-alpha.8

Reproduction link

https://codesandbox.io/s/kind-franklin-cq3le

Steps to reproduce

Define a boolean prop and use it as an empty attribute

What is expected?

props should be true

What is actually happening?

props is the empty string


I have a PR ready

jods4 added a commit to jods4/vue-next that referenced this issue Mar 15, 2020
yyx990803 pushed a commit that referenced this issue Mar 16, 2020
@jods4
Copy link
Contributor Author

jods4 commented Mar 16, 2020

@yyx990803 I just noticed another issue with the boolean conversion that my PR didn't fix.
Code works properly but both tests and runtime produce the following warning:

Invalid prop: type check failed for prop "active". Expected Boolean, got String with value "".

@jods4
Copy link
Contributor Author

jods4 commented Mar 17, 2020

Also I learned a new trick today. It's more obscure but maybe more efficent, >>> always returns a positive integer, even in edge case >>> 0. So -1 >>> 0 == 4294967295

So where my PR did
stringIndex < 0 || booleanIndex < stringIndex
you could do, if you're into bit tricks:
booleanIndex < (stringIndex >>> 0)
It might be shorter code and maybe more efficient, it's definitely more obscure.
Brackets are not required and would be removed by minification, but they make the expression easier to understand.

@yyx990803
Copy link
Member

Fixed the boolean validation issue in 3b282e7.
Re the trick: I think we should stick to something that's easier to understand.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants