From 0700c51a85bc4f5492d9d085ec7251a3753074ba Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Wed, 27 Apr 2011 16:16:05 +0200 Subject: [PATCH] Simplifications in Item#isDescendant & Item#isAncestor. --- src/item/Item.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/item/Item.js b/src/item/Item.js index dd7f8da7..f2ab353c 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -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; },