-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Support for reactivity on sub-classed Arrays #6943
Comments
This will be supported in future versions. See #5893 (comment)
|
@posva thanks for the reference and good to know you are looking to address this at some point in the future. I needed to have this addressed sooner, rather than later, so I have forked the project and applied a solution to it. You can view it here if you like: Test cases are passing and I will now continue on with its usage on my project. If there is any interest in taking that as a contribution, I will be happy to make it. (BTW: one test cases was failing even before I made any changes (test: transition out-in on async component (resolve after leave complete)... Just FYI) For anyone finding this and wanting to use the work-around until the Vue team is ready to introduce this feature: I have created a branch in my forked repo that includes the built files with my changes. You can use it by:
|
Thanks @purtuga - that's an interesting approach. While for core we will probably hold on for this, there are a few things that can be improved for your fork. In particular, you are creating a fresh prototype object for every Array being observed, but technically you only need to create a wrapper prototype object once for each original prototype object. This cost can be avoided by having a Map that serves as a cache. |
Thank @yyx990803 for taking the time to look at the fork. Thanks again. Looking forward to when this feature lands on VueJS. |
Honestly don't know why Array subclass worked before. Refer to vuejs/vue#4049, vuejs/vue#6943, vuejs/vue#5893.
Honestly don't know why Array subclass worked before. Refer to vuejs/vue#4049, vuejs/vue#6943, vuejs/vue#5893.
Honestly don't know why Array subclass worked before. Refer to vuejs/vue#4049, vuejs/vue#6943, vuejs/vue#5893.
What problem does this feature solve?
Support sub-classed arrays.
Prevent vueJS from completely removing the subclassed array's prototype and revert it back to the native Array prototype. This in turn breaks other application code that was expecting the array to have the extended methods.
Example:
(Related to #6920)
What does the proposed API look like?
No API changes.
This feature request is simply to request that an array prototype, when replaced in support of Vue's reactivity, continue to call the
super
method of that array instance when wrapped with VueJS's mutator code.The text was updated successfully, but these errors were encountered: