Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'tree-size' into dev-master

  • Loading branch information...
commit 0ddeea9ae853a4b09afdf3bb7b0980fb4718bb0d 2 parents 903b2a9 + ee170c3
@rgrove rgrove authored
View
6 src/tree/HISTORY.md
@@ -1,6 +1,12 @@
Tree Change History
===================
+@VERSION@
+-----
+
+* Fixed: The number returned by `Tree#size()` didn't include the root node.
+ [Ryan Grove]
+
3.9.1
-----
View
2  src/tree/js/tree.js
@@ -528,7 +528,7 @@ var Tree = Y.Base.create('tree', Y.Base, [], {
@return {Number} Total number of nodes in this tree.
**/
size: function () {
- return this.rootNode.size();
+ return this.rootNode.size() + 1;
},
/**
View
10 src/tree/tests/unit/assets/tree-test.js
@@ -477,8 +477,8 @@ treeSuite.add(new Y.Test.Case({
Assert.isTrue(node.state.destroyed, 'node should be destroyed');
},
- 'size() should return the total number of nodes in the tree': function () {
- Assert.areSame(6, this.tree.size());
+ 'size() should return the total number of nodes in the tree, including the root node': function () {
+ Assert.areSame(7, this.tree.size());
},
'toJSON() should return a serializable object representing the tree': function () {
@@ -731,7 +731,7 @@ treeSuite.add(new Y.Test.Case({
});
this.tree.insertNode(this.tree.rootNode, {id: 'added'});
- Assert.areSame(6, this.tree.size(), 'node should not have been added');
+ Assert.areSame(7, this.tree.size(), 'node should not have been added');
},
'`clear` event should be preventable': function () {
@@ -740,7 +740,7 @@ treeSuite.add(new Y.Test.Case({
});
this.tree.clear();
- Assert.areSame(6, this.tree.size(), 'tree should not have been cleared');
+ Assert.areSame(7, this.tree.size(), 'tree should not have been cleared');
},
'`remove` event should be preventable': function () {
@@ -749,7 +749,7 @@ treeSuite.add(new Y.Test.Case({
});
this.tree.removeNode(this.tree.children[0]);
- Assert.areSame(6, this.tree.size(), 'node should not have been removed');
+ Assert.areSame(7, this.tree.size(), 'node should not have been removed');
}
}));
Please sign in to comment.
Something went wrong with that request. Please try again.