mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 03:01:51 +08:00
fix(core): ignore inserting child if < 0 (#10690)
This commit is contained in:
@ -49,14 +49,14 @@ export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefi
|
||||
this._registerLayoutChild(child);
|
||||
}
|
||||
|
||||
public insertChild(child: View, atIndex: number): void {
|
||||
if (atIndex < 0) {
|
||||
throw new Error('Cannot insert a child to a negative index.');
|
||||
public insertChild(child: View, atIndex: number): boolean {
|
||||
if (atIndex > -1) {
|
||||
this._subViews.splice(atIndex, 0, child);
|
||||
this._addView(child, atIndex);
|
||||
this._registerLayoutChild(child);
|
||||
return true;
|
||||
}
|
||||
|
||||
this._subViews.splice(atIndex, 0, child);
|
||||
this._addView(child, atIndex);
|
||||
this._registerLayoutChild(child);
|
||||
return false;
|
||||
}
|
||||
|
||||
public removeChild(child: View): void {
|
||||
|
Reference in New Issue
Block a user