Simplifications in Item#isDescendant & Item#isAncestor.

This commit is contained in:
Jonathan Puckey 2011-04-27 16:16:05 +02:00
parent 55fc2bc99c
commit 0700c51a85

View file

@ -375,11 +375,10 @@ var Item = this.Item = Base.extend({
* @return {@true if it is inside the specified item}
*/
isDescendant: function(item) {
var parent = this.parent;
while (parent) {
var parent = this;
while (parent = parent.parent) {
if (parent == item)
return true;
parent = parent.parent;
}
return false;
},
@ -400,11 +399,10 @@ var Item = this.Item = Base.extend({
* @return {@true if the item is an ancestor of the specified item}
*/
isAncestor: function(item) {
var parent = item.parent;
while (parent) {
var parent = item;
while (parent = parent.parent) {
if (parent == this)
return true;
parent = parent.parent;
}
return false;
},