Skip to content

Commit

Permalink
Raise an exception if a view is added to itself as a subview.
Browse files Browse the repository at this point in the history
This is better than a DOM node exception.
  • Loading branch information
aljungberg committed Mar 27, 2012
1 parent 099ee1e commit 38f8b1a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions AppKit/CPView.j
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 38f8b1a

Please sign in to comment.