Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When a tree model is replaced by a new object, even if that object's contents are identical to the previous value, the entire treecontrol is reloaded from scratch, and since each node has its own scope, the tree appears to forget what has been expanded or selected when the "new" nodes are attached with their new scopes. Additionally, if you expand/select an item, then collapse and re-expand any of its parents, the same symptom applies to the children of the re-expanded node, for the same reason.
This PR fixes both scenarios by first detecting whether a "new" tree model is any different from the previous version, and doing nothing if not, then by using a configurable equality function to determine whether a new node is equivalent to an old one, and applying the old one's expanded/selected status to the new. The default equality function, as indicated in the updated README, first discards any child nodes, then returns the result of
angular.equals()
against the old and new nodes.Also added tests (and fixed bugs that prevented them from passing on the first attempt) and updated package.json to agree with bower.json on the package version.