Skip to content

Fix corner case and add v-model support when prop validation #2241

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

Merged
merged 8 commits into from
Sep 6, 2020

Conversation

yoyo930021
Copy link
Member

@yoyo930021 yoyo930021 commented Sep 4, 2020

Fixed #2236
Fixed #2237

@yoyo930021 yoyo930021 changed the title Fix props validator Fix corner case and add v-model support when prop validation Sep 4, 2020
@yoyo930021 yoyo930021 force-pushed the fix-props-validator branch 2 times, most recently from 1bc21df to 6de96f9 Compare September 4, 2020 11:04
@octref octref force-pushed the fix-props-validator branch from 6de96f9 to cd25383 Compare September 4, 2020 16:09
normalized: normalizeHtmlAttributeNameToKebabCase(attr)
normalized: normalizeHtmlAttributeNameToKebabCase(
attr,
definedProps.find(prop => prop.defaultModel)?.name ?? 'value'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would write my logic here:

  • If it's v-model, create a function such as normalizeModelAttr that takes in the definedProps and find it's normalized prop. You can make this function use normalizeHtmlAttributeNameToKebabCase.
  • If it's not, use normalizeHtmlAttributeNameToKebabCase directly

Currently this function is overloaded with too many things. Make one function do one thing is better (and then compose them).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hesitated when I wrote this function,
but I'm writing this anyway.

I will send a PR to refactor it.

@octref octref force-pushed the fix-props-validator branch from 3e05152 to 18ba3e9 Compare September 6, 2020 08:47
@octref
Copy link
Member

octref commented Sep 6, 2020

Sorry I didn't wait. I'm planning to make a release soon to address the folidng issue and this issue, so I made the changes myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants