Skip to content

Computed, have an issue when sorting #8661

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

Closed
Miguelrn opened this issue Aug 15, 2018 · 1 comment
Closed

Computed, have an issue when sorting #8661

Miguelrn opened this issue Aug 15, 2018 · 1 comment

Comments

@Miguelrn
Copy link

Miguelrn commented Aug 15, 2018

Version

2.5.17-beta.0

Reproduction link

https://jsfiddle.net/Pomer/vdq3wbtL/1/

Steps to reproduce

Simple you can change Vue from 2.5.17 to 2.5.17-beta and the jsfiddle will stop working.
The idea it's simple we have an array of json componen than need to be sorted via computed function.

What is expected?

array of elements sorted, instead we get an error and nothing shown.

What is actually happening?

It seems to have an infinite loop, since i can set a console.log before the return statement of the computed function and see how many times its been called this function.


stacktrace:

vue.js:597 [Vue warn]: Error in render: "RangeError: Maximum call stack size exceeded"
(found` in <Root>)
warn @ vue.js:597
logError @ vue.js:1740
globalHandleError @ vue.js:1735
handleError @ vue.js:1724
Vue._render @ vue.js:4562
updateComponent @ vue.js:2779
get @ vue.js:3144
Watcher @ vue.js:3132
mountComponent @ vue.js:2786
Vue.$mount @ vue.js:8557
Vue.$mount @ vue.js:10957
Vue._init @ vue.js:4652
Vue @ vue.js:4739
(anonymous) @ main.js:9
vue.js:1744 RangeError: Maximum call stack size exceeded   
    at Watcher.get (vue.js:3158)
    at Watcher.getAndInvoke (vue.js:3244)
    at Watcher.update (vue.js:3222)
    at Dep.notify (vue.js:703)
    at Array.mutator (vue.js:851)
    at Vue.testSort (main.js:89)
    at Watcher.get (vue.js:3144)
    at Watcher.getAndInvoke (vue.js:3244)
    at Watcher.update (vue.js:3222)
    at Dep.notify (vue.js:703)
@posva
Copy link
Member

posva commented Aug 15, 2018

This is probably related to #8446, closing as a duplicate

However, sort modifies the original array, you should create a new one with slice() first and it will work

@posva posva closed this as completed Aug 15, 2018
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