do not remove an element while splicing
This commit is contained in:
parent
3a2b28eb76
commit
332a734288
2 changed files with 11 additions and 3 deletions
|
|
@ -76,7 +76,7 @@ The numeric index. 0 is the first object.
|
|||
|
||||
sub addObjectAt {
|
||||
my ( $self, $object, $position ) = @_;
|
||||
splice @{$self->objects}, $position, 1, $object;
|
||||
splice @{$self->objects}, $position, 0, $object;
|
||||
return $object;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -249,8 +249,16 @@ $tab = $fb->addTab( tabset => 'one', name => 'one' );
|
|||
$fset = $fb->addFieldset( name => 'three', label => 'Three' );
|
||||
$field2 = $fb->addFieldAt( WebGUI::Form::Text->new( $session, name => "two" ), 2 );
|
||||
|
||||
is( $fb->objects->[2], $field2, 'objects array is correct' );
|
||||
is( $fb->fields->[1], $field2, 'fields array is correct' );
|
||||
cmp_deeply(
|
||||
$fb->objects,
|
||||
[ $field, $fb->getTabset('one'), $field2, $fset ],
|
||||
'objects array is correct',
|
||||
);
|
||||
cmp_deeply(
|
||||
$fb->fields,
|
||||
[ $field, $field2 ],
|
||||
'fields array is correct',
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Serialize and deserialize
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue