From 38f8b1a931cf07af6094dfd6377e12de3958bc0e Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Tue, 27 Mar 2012 10:02:27 +0100 Subject: [PATCH] Raise an exception if a view is added to itself as a subview. This is better than a DOM node exception. --- AppKit/CPView.j | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 0c26e5a54..62c06e092 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -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;