@@ -205,12 +205,15 @@ class Control
205
205
206
206
if p
207
207
if p[ " __class" ]
208
- _rootParent = p. __class. __parent
209
- while _rootParent != Control
210
- _rootParent = _rootParent. __parent
208
+ if p. __class != Control
209
+ _rootParent = p. __class. __parent
210
+ while _rootParent != Control
211
+ _rootParent = _rootParent. __parent
211
212
else
212
213
error " parent must a class."
213
214
215
+ _rootParent = _rootParent or p
216
+
214
217
assert ( p == nil ) or ( p. __class == Control ) or ( _rootParent. __class == Control ) ,
215
218
" parent must be nil or Control or a subclass of Control."
216
219
@@ -240,12 +243,15 @@ class Control
240
243
local _rootParent
241
244
242
245
if child[ " __class" ]
243
- _rootParent = child. __class. __parent
244
- while _rootParent != Control
245
- _rootParent = _rootParent. __parent
246
+ if child. __class != Control
247
+ _rootParent = child. __class. __parent
248
+ while _rootParent != Control
249
+ _rootParent = _rootParent. __parent
246
250
else
247
251
error " parent must a class."
248
252
253
+ _rootParent = _rootParent or child
254
+
249
255
assert ( child. __class == Control ) or ( _rootParent. __class == Control ) ,
250
256
" child must be Control or a subclass of Control."
251
257
@@ -464,12 +470,14 @@ class Control
464
470
local _rootParent
465
471
466
472
if target[ " __class" ]
467
- _rootParent = target. __class. __parent
468
- while _rootParent != Control
469
- _rootParent = _rootParent. __parent
473
+ if target. __class != Control
474
+ _rootParent = target. __class. __parent
475
+ while _rootParent != Control
476
+ _rootParent = _rootParent. __parent
470
477
else
471
478
error " target must a class."
472
-
479
+
480
+ _rootParent = _rootParent or target
473
481
assert ( target. __class == Control ) or ( _rootParent. __class == Control ) ,
474
482
" target must be a Control or a subclass of Control."
475
483
0 commit comments