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

TypeError for Ember.computed.sort in DependentArraysObserver.prototype.dependentArrayWillChange #5596

Closed
rhyek opened this issue Sep 17, 2014 · 3 comments
Labels

Comments

@rhyek
Copy link

rhyek commented Sep 17, 2014

I'm using Ember 1.7 and having an issue with DependentArraysObserver.prototype.dependentArrayWillChange at line 25860 (http://builds.emberjs.com/tags/v1.7.0/ember.js) where a TypeError is raised because observerContexts[sliceIndex] is undefined:

observerContexts[sliceIndex].destroyed = true;

I have a jsbin here. (click on 'clear'). The problem only seems to occur in the specific case where i have both sortableTable views up (even though they're independent of each other) and at least the second has it's Ember.computed.sort computed property's sortProperties set to a non-empty array.

I've noticed that just before the exception is raised, at line 25815 when this line is called inside trackRemove:

var trackedArray = this.trackedArraysByGuid[dependentKey];

trackedArray is undefined while dependentArray still points to my underlying data.

In any case, changing this:

function removeObservers(propertyKey) {
    observerContexts[sliceIndex].destroyed = true;
    removeBeforeObserver(item, propertyKey, this, observerContexts[sliceIndex].beforeObserver);
    removeObserver(item, propertyKey, this, observerContexts[sliceIndex].observer);
}

to this:

function removeObservers(propertyKey) {
    if (typeof observerContexts[sliceIndex] !== 'undefined') {
        observerContexts[sliceIndex].destroyed = true;
        removeBeforeObserver(item, propertyKey, this, observerContexts[sliceIndex].beforeObserver);
        removeObserver(item, propertyKey, this, observerContexts[sliceIndex].observer);
    }
}

solves my problem.

@wagenet
Copy link
Member

wagenet commented Nov 1, 2014

@rhyek can you check this in 1.8?

@rhyek
Copy link
Author

rhyek commented Nov 1, 2014

Just updated that jsbin to ember 1.8.0 and ember-data 1 beta 11. Still has the same issue.

http://emberjs.jsbin.com/kiqipiguqi/1/edit

@wagenet
Copy link
Member

wagenet commented Nov 1, 2014

Merging into #9462

@wagenet wagenet closed this as completed Nov 1, 2014
@wagenet wagenet mentioned this issue Nov 1, 2014
7 tasks
stefanpenner added a commit that referenced this issue Jun 23, 2015
#9492, #5319, #5268, #4831] Move away from AC/RC instead use the simpler naive enumerable methods, and rely on glimmers stable rendering for efficiency.

For more complex scenarios, custom solutions should be used.

@wagenet & @stefanpenner
stefanpenner added a commit to stefanpenner/ember.js that referenced this issue Jun 26, 2015
…rjs#9462, emberjs#4919, emberjs#4231, emberjs#3706, emberjs#5596, emberjs#9485, emberjs#9492, emberjs#5319, emberjs#5268, emberjs#4831, emberjs#5558] Move away from AC/RC instead use the simpler naive enumerable methods, and rely on glimmers stable rendering for efficiency.

For more complex scenarios, custom solutions should be used.

@wagenet & @stefanpenner
stefanpenner added a commit that referenced this issue Jun 28, 2015
#5596, #9485, #9492, #5319, #5268, #4831, #5558] Move away from AC/RC instead use the simpler naive enumerable methods, and rely on glimmers stable rendering for efficiency.

For more complex scenarios, custom solutions should be used.

@wagenet & @stefanpenner

(cherry picked from commit 0dc1a6c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants