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

Resolved issue with removeObserver and @each #541

Merged
merged 1 commit into from Sep 27, 2011

Conversation

omghax
Copy link
Contributor

@omghax omghax commented Jul 6, 2011

Here's a patch for an issue I was running into when adding and removing content observers at runtime. I would start out by adding an observer for something like @each.name and then later on replace it with one on @each.age.

The problem is that SC._ChainObserver.destroyChain doesn't remove content observers, so when I removed the @each.name observer, "name" would still be in the _kvo_content_observed_keys set, and when I then added the @each.age observer, _setupContentObservers would loop through those keys and find "name", even though the observer itself had been set to null. It would then call _resumeChainObservingForItemWithChainObserver and pass in null as the second argument (observer), which would throw an error because it would try to access observer.property.

To fix this I added a special case for @each in destroyChain, which calls _removeContentObserver on the object. Tests are included.

ColinCampbell pushed a commit that referenced this pull request Sep 27, 2011
Resolved issue with removeObserver and @each
@ColinCampbell ColinCampbell merged commit 328be9c into sproutcore:master Sep 27, 2011
@ColinCampbell
Copy link
Contributor

Great stuff, thanks :)

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

Successfully merging this pull request may close these issues.

None yet

2 participants