Raise an exception if a view is added to itself as a subview.

This is better than a DOM node exception.
This commit is contained in:
Alexander Ljungberg
2012-03-27 10:02:27 +01:00
parent 099ee1e249
commit 38f8b1a931
+3
View File
@@ -369,6 +369,9 @@ var CPViewFlags = { },
/* @ignore */
- (void)_insertSubview:(CPView)aSubview atIndex:(int)anIndex
{
if (aSubview === self)
[CPException raise:CPInvalidArgumentException reason:"can't add a view as a subview of itself"];
// We will have to adjust the z-index of all views starting at this index.
var count = _subviews.length;