Michael Alan Dorman <[EMAIL PROTECTED]> writes:

> Because the <input type="button"> tag doesn't allow text other than
> the value to be displayed in the button, I've had to start using the
> <button> tag on some of my pages.  Imagine my dismay when this caused
> WWW::Mechanize to no longer recognize that my form had buttons!

Nobody complained before so I guess they are not used much.

> After poking around WWW::Mechanize for a bit, I was led to HTML::Form,
> which doesn't currently recognize <button> tags.  This patch certainly
> fixes the issue I was having, and I think it represents a generally
> applicable enhancement.  I'd love to see it included in the next drop
> of libwww-perl.

Looks good.  Would be even better if you also updated the test suite.
I'll get in included in the next release.  Currely I have problems
accessing soureforge so I'm not able to get it checked in.

> --- Form.pm.orig      2004-06-16 06:41:23.000000000 -0400
> +++ Form.pm   2004-07-19 11:03:31.000000000 -0400
> @@ -96,7 +96,7 @@
>      my $p = HTML::TokeParser->new(ref($html) ? $html->content_ref : \$html);
>      eval {
>       # optimization
> -     $p->report_tags(qw(form input textarea select optgroup option keygen));
> +     $p->report_tags(qw(button form input textarea select optgroup option keygen));
>      };
>  
>      unless (defined $base_uri) {
> @@ -130,6 +130,11 @@
>                   $attr->{value_name} = $p->get_phrase;
>                   $f->push_input($type, $attr);
>               }
> +             elsif ($tag eq "button") {
> +                 my $type = delete $attr->{type} || "submit";
> +                 $attr->{value_name} = $p->get_phrase;
> +                 $f->push_input($type, $attr);

I don't think we should support <button type="checkbox"> and similar
so I suggest we only push the input if the $type is submit at this
point.

> +             }
>               elsif ($tag eq "textarea") {
>                   $attr->{textarea_value} = $attr->{value}
>                       if exists $attr->{value};

Regards,
Gisle

Reply via email to