HTML-DOM
view release on metacpan or search on metacpan
t/form-element.t view on Meta::CPAN
ok!$elem->disabled , 'button: get disabled';
ok!$elem->disabled(1), , 'button: set/get disabled';
ok $elem->disabled , 'button: get disabled again';
is $elem->getAttribute('disabled'), 'disabled',
'buttonâs disabled is set to "disabled" when true';
$elem->disabled($false);
is $elem->attr('disabled'), undef,
'buttonâs disabled is deleted when set to false';
$elem->attr(name => 'Achaimenides');
test_attr $elem, qw-name Achaimenides Gormistas-;
$elem->attr(tabindex => '7');
$elem->attr(value => 'not much');
test_attr $elem, qw-tabIndex 7 8 -;
test_attr $elem, value=> 'not much','a lot' ;
$elem->attr(type => 'bUtton');
is $elem->type, 'button', 'button->type';
}
# -------------------------#
use tests 9; # HTMLLabelElement
{
is ref(
my $elem = $doc->createElement('label'),
), 'HTML::DOM::Element::Label',
"class for label";
is_deeply [$elem->form], [], 'label->form when there isnât one';
$form->appendChild($elem);
is $elem->form, $form, 'label->form';
$elem->attr(accesskey => 'F');
$elem->attr(for => 'me');
test_attr $elem, qw-accessKey F G -;
test_attr $elem, qw-htmlFor me &you-;
}
# -------------------------#
use tests 3; # HTMLFieldSetElement
{
is ref(
my $elem = $doc->createElement('fieldset'),
), 'HTML::DOM::Element::FieldSet',
"class for fieldset";
is_deeply [$elem->form], [], 'fieldset->form when there isnât one';
$form->appendChild($elem);
is $elem->form, $form, 'fieldset->form';
}
# -------------------------#
use tests 9; # HTMLLegendElement
{
is ref(
my $elem = $doc->createElement('legend'),
), 'HTML::DOM::Element::Legend',
"class for legend";
is_deeply [$elem->form], [], 'legend->form when there isnât one';
$form->appendChild($elem);
is $elem->form, $form, 'legend->form';
$elem->attr(accesskey => 'F');
$elem->attr(align => 'LEFT');
test_attr $elem, qw-accessKey F G -;
test_attr $elem, qw-align left right -;
}
# -------------------------#
use tests 7; # HTML::DOM::Collection::Elements
{
my $elem = $doc->createElement('form');
$elem->appendChild($doc->createElement('input')) for 1..4;
$_->type('checkbox'), $_->name('foo') for ($elem->childNodes)[0,1];
$_->type('radio'), $_->name('bar') for ($elem->childNodes)[2,3];
ok $elem->elements->{foo}->DOES('HTML::DOM::NodeList'),
'hdce returns a nodelist for multiple equinominal elems';
ok $elem->elements->{bar}->DOES('HTML::DOM::NodeList'),
'but letâs check it again, just to be sure';
is $elem->elements->{foo}->[0], $elem->childNodes->[0],
'contents of hdceâs special node lists (1)';
is $elem->elements->{foo}->[1], $elem->childNodes->[1],
'contents of hdceâs special node lists (2)';
is $elem->elements->{bar}->[0], $elem->childNodes->[2],
'contents of hdceâs special node lists (3)';
is $elem->elements->{bar}->[1], $elem->childNodes->[3],
'contents of hdceâs special node lists (4)';
my $foo = $elem->elements->{bar};
ok $foo->length,
'the nodelist returned by the collection continues to ' .
'work when the nodelist is out of scope';
# I mistakenly had a misplaced weaken() during development.
}
# -------------------------#
use tests 7; # reset
{
my $doc = new HTML::DOM;
$doc->write('
<title></title>
<form name=f>
<input type=radio name=foo checked id=foo1>
<input type=radio name=foo id=foo2>
<input type=checkbox checked name=chek1>
<input type=checkbox name=chek2>
<input type=text name=tekxt value=defufou>
<input type=password name=etet value=",fdbjq">
<select name=multi multiple>
<option selected>
<option selected>
<option>
<option>
</select>
<select name=cyngle>
<option>
<option selected>
<option>
<option>
( run in 1.491 second using v1.01-cache-2.11-cpan-39bf76dae61 )