X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FDOM-Tiny.git;a=blobdiff_plain;f=lib%2FDOM%2FTiny.pm;h=0eecb5e7b8d2b90060e3f332af8ea5e22ba7d7d0;hp=f7da74c1c9191937e52bb3496d64d814dd1143ff;hb=4b5e2513f7ea1ac132c1bb5c6732516d6cb1b917;hpb=4d7ffd9750b680d72934879b281bce45448807a4 diff --git a/lib/DOM/Tiny.pm b/lib/DOM/Tiny.pm index f7da74c..0eecb5e 100644 --- a/lib/DOM/Tiny.pm +++ b/lib/DOM/Tiny.pm @@ -170,6 +170,11 @@ sub val { return defined($self->{value}) ? $self->{value} : $self->text if (my $tag = $self->tag) eq 'option'; + # "input" ("type=checkbox" and "type=radio") + my $type = $self->{type} || ''; + return defined $self->{value} ? $self->{value} : 'on' + if $tag eq 'input' && ($type eq 'radio' || $type eq 'checkbox'); + # "textarea", "input" or "button" return $tag eq 'textarea' ? $self->text : $self->{value} if $tag ne 'select'; @@ -235,7 +240,7 @@ sub _content { my $tree = $self->tree; unless ($tree->[0] eq 'root' || $tree->[0] eq 'tag') { my $old = $self->content; - return $self->content($start ? "$old$new" : "$new$old"); + return $self->content($start ? $old . $new : $new . $old); } $start = $start ? ($#$tree + 1) : _start($tree); @@ -1234,7 +1239,7 @@ C attribute and return an array reference with all values, or C if none could be found. # "a" - $dom->parse('')->at('input')->val; + $dom->parse('')->at('input')->val; # "b" $dom->parse('')->at('textarea')->val; @@ -1250,6 +1255,9 @@ C if none could be found. $dom->parse('') ->at('select')->val->[0]; + # "on" + $dom->parse('')->at('input')->val; + =head2 wrap $dom = $dom->wrap('
');