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

Open
wants to merge 2 commits into
base: dev
Choose a base branch
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.

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

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.

2 participants