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

Vue does not check if ob is defined. #12042

Closed
AimForNaN opened this issue Apr 28, 2021 · 2 comments
Closed

Vue does not check if ob is defined. #12042

AimForNaN opened this issue Apr 28, 2021 · 2 comments

Comments

@AimForNaN
Copy link

Version

2.6.11

Reproduction link

https://jsfiddle.net/cdzos023/

Steps to reproduce

See fiddle.


Since upgrading to Vue 3 is not currently a viable option, I perform a small hack to make my class (which is a subclass of Array) reactive while maintaining its identity. This, however, results in an error when I try to call sort on it.

A simple fix could be checking if ob is defined before attempting to access any of its members.

if (inserted) ob.observeArray(inserted)

ob.dep.notify()

@posva
Copy link
Member

posva commented Apr 28, 2021

Duplicate of #9259

@posva posva marked this as a duplicate of #9259 Apr 28, 2021
@posva posva closed this as completed Apr 28, 2021
@AimForNaN
Copy link
Author

I can understand why this would be considered a duplicate of #9259, but the solution differs in extremity. I'm not asking to rewrite Vue 2. A simple if statement would overcome my issue.

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

No branches or pull requests

2 participants