mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-06 17:12:50 +00:00
Fix for addSubview:positioned:relativeTo: not working with view already in the view treey.
Reviewed by me.
This commit is contained in:
1 parent
6e15ce0c00
commit
7d8b02dd96
1 file changed
+9
-5
+9
-5
@@ -288,11 +288,11 @@ var DOMElementPrototype = nil,
|
||||
var index = anotherView ? [_subviews indexOfObjectIdenticalTo:anotherView] : CPNotFound;
|
||||
|
||||
// In other words, if no view, then either all the way at the bottom or all the way at the top.
|
||||
if (index == CPNotFound)
|
||||
index = (anOrderingMode == CPWindowAbove) ? [_subviews count] : 0;
|
||||
if (index === CPNotFound)
|
||||
index = (anOrderingMode === CPWindowAbove) ? [_subviews count] : 0;
|
||||
|
||||
// else, if we have a view, above if above.
|
||||
else if (anOrderingMode == CPWindowAbove)
|
||||
else if (anOrderingMode === CPWindowAbove)
|
||||
++index;
|
||||
|
||||
[self _insertSubview:aSubview atIndex:index];
|
||||
@@ -309,7 +309,8 @@ var DOMElementPrototype = nil,
|
||||
{
|
||||
var index = [_subviews indexOfObjectIdenticalTo:aSubview];
|
||||
|
||||
if (index == anIndex || index == count - 1 && anIndex == count)
|
||||
// FIXME: should this be anIndex >= count? (last one)
|
||||
if (index === anIndex || index === count - 1 && anIndex === count)
|
||||
return;
|
||||
|
||||
[_subviews removeObjectAtIndex:index];
|
||||
@@ -320,6 +321,9 @@ var DOMElementPrototype = nil,
|
||||
|
||||
if (anIndex > index)
|
||||
--anIndex;
|
||||
|
||||
//We've effectively made the subviews array shorter, so represent that.
|
||||
--count;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -336,7 +340,7 @@ var DOMElementPrototype = nil,
|
||||
aSubview._superview = self;
|
||||
}
|
||||
|
||||
if (anIndex == CPNotFound || anIndex >= count)
|
||||
if (anIndex === CPNotFound || anIndex >= count)
|
||||
{
|
||||
_subviews.push(aSubview);
|
||||
|
||||
|
||||
Reference in new issue
Block a user