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

Refactor: Utilize Vue's built-in defineModel for model implementation #906

Closed
wants to merge 2 commits into from

Conversation

PiotrWasak
Copy link

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This PR refactors the code to use Vue's built-in defineModel instead of relying on custom libraries. By leveraging Vue's native functionality:

The codebase is simplified with less code.
External library dependencies are no longer needed for this functionality.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Sorry, something went wrong.

Piotr Wasak added 2 commits November 16, 2024 13:58

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Comment on lines +10 to +11
const modelValue = defineModel<string | number>()
modelValue.value = props.defaultValue
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const modelValue = defineModel<string | number>()
modelValue.value = props.defaultValue
const modelValue = defineModel<string | number>({
default: props.defaultValue
})

Copy link
Author

Choose a reason for hiding this comment

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

It cannot be done like that, already tried it 😁
"[@vue/compiler-sfc] defineModel() in <script setup> cannot reference locally declared variables because it will be hoisted outside of the setup() function."

@sadeghbarati
Copy link
Collaborator

sadeghbarati commented Dec 3, 2024 β€’

I think it is soon to include this macro in the components cause this macro added from 3.4+

Let's see what other's opinion is

@zernonia
Copy link
Member

I think due to Vue's current limitation (defineModel can't access props.defaultValue), we can't move forward with this PR. I'll be closing it πŸ™πŸΌ

@zernonia zernonia closed this Feb 22, 2025
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.

None yet

3 participants