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

useVModel break with vue 2.7 and vue-demi #1745

Closed
7 tasks done
b4n92uid opened this issue Jul 4, 2022 · 4 comments · Fixed by #1798 or #1898
Closed
7 tasks done

useVModel break with vue 2.7 and vue-demi #1745

b4n92uid opened this issue Jul 4, 2022 · 4 comments · Fixed by #1798 or #1898

Comments

@b4n92uid
Copy link

b4n92uid commented Jul 4, 2022

Describe the bug

Hello everyone, first thanks for the incredible toolset of composables function

So useVModel is trying to get the emit function directly from the VM :

const _emit = emit || vm?.emit || vm?.$emit?.bind(vm)

const _emit = emit || vm?.emit || vm?.$emit?.bind(vm)

And as stated here by the vue author we should not rely on other than proxy to use the current instance:
vuejs/vue#12596 (comment)

So this can be refactored as (in backward compatible manner):
const _emit = emit || vm?.emit || vm?.$emit?.bind(vm) || vm?.proxy?.emit

Reproduction

N/A

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
    Memory: 6.45 GB / 15.97 GB
  Binaries:
    Node: 16.8.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 7.21.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (103.0.1264.44)
    Internet Explorer: 11.0.19041.1566

Used Package Manager

yarn

Validations

@b4n92uid b4n92uid changed the title useVModel break with vue 2.7 useVModel break with vue 2.7 and vue-demi Jul 4, 2022
@antfu
Copy link
Member

antfu commented Jul 4, 2022

Looks good, PR welcome

@JiuRanYa
Copy link
Contributor

JiuRanYa commented Jul 8, 2022

I create a PR #1798

@Staremang
Copy link
Contributor

Problem not resolved

Error:

console.log(vm?.proxy?.emit) // undefined

Fixed:

console.log(vm?.proxy?.$emit)

@Shimada666
Copy link

I create a PR #1798

I used the latest version(v8.9.2) but it still doesn't work. Maybe @Staremang's PR can fix that. Could you please review and merge it? Thanks! @antfu

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