- the val method returns "on" by default for checkbox or radio inputs with no value
- Merge several CSS bugfixes and improvements from Mojolicious 6.31 and 6.32.
- Merge wrap and wrap_content bugfixes from Mojolicious 6.34.
- Fix small html_unescape bug in DOM::Tiny::Entities
+ - Merge handling of "on" default values in val method from Mojolicious 6.49.
0.002 2015-11-09 19:28:42 EST
- Support perl 5.8 (mst)
"Dan Book <dbook@cpan.org>"
],
"dynamic_config" : 0,
- "generated_by" : "Dist::Zilla version 5.042, CPAN::Meta::Converter version 2.150005",
+ "generated_by" : "Dist::Zilla version 5.043, CPAN::Meta::Converter version 2.150005",
"license" : [
"artistic_2"
],
-# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.042.
+# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.043.
use strict;
use warnings;
C<undef> if none could be found.
# "a"
- $dom->parse('<input name="test" value="a">')->at('input')->val;
+ $dom->parse('<input name=test value=a>')->at('input')->val;
# "b"
$dom->parse('<textarea>b</textarea>')->at('textarea')->val;
$dom->parse('<select multiple><option selected>e</option></select>')
->at('select')->val->[0];
+ # "on"
+ $dom->parse('<input name=test type=checkbox>')->at('input')->val;
+
=head2 wrap
$dom = $dom->wrap('<div></div>');
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';
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);
C<undef> if none could be found.
# "a"
- $dom->parse('<input name="test" value="a">')->at('input')->val;
+ $dom->parse('<input name=test value=a>')->at('input')->val;
# "b"
$dom->parse('<textarea>b</textarea>')->at('textarea')->val;
$dom->parse('<select multiple><option selected>e</option></select>')
->at('select')->val->[0];
+ # "on"
+ $dom->parse('<input name=test type=checkbox>')->at('input')->val;
+
=head2 wrap
$dom = $dom->wrap('<div></div>');
# "n", "4n", "+4n", "-4n", "n+1", "4n-1", "+4n-1" (and other variations)
return [0, 0]
unless $equation =~ /^\s*((?:\+|-)?(?:\d+)?)?n\s*((?:\+|-)\s*\d+)?\s*$/i;
- return [$1 eq '-' ? -1 : $1 eq '' ? 1 : $1, join('', split(' ', $2 || 0))];
+ return [$1 eq '-' ? -1 : !length $1 ? 1 : $1, join('', split(' ', $2 || 0))];
}
sub _match {
<form action="/foo">
<p>Test</p>
<input type="text" name="a" value="A" />
+ <input type="checkbox" name="q">
<input type="checkbox" checked name="b" value="B">
+ <input type="radio" name="r">
<input type="radio" checked name="c" value="C">
+ <input name="s">
+ <input type="checkbox" name="t" value="">
+ <input type=text name="u">
<select multiple name="f">
<option value="F">G</option>
<optgroup>
is $dom->at('textarea')->val, 'M', 'right value';
is $dom->at('button')->val, 'O', 'right value';
is $dom->find('form input')->last->val, 'P', 'right value';
+is $dom->at('input[name=q]')->val, 'on', 'right value';
+is $dom->at('input[name=r]')->val, 'on', 'right value';
+is $dom->at('input[name=s]')->val, undef, 'no value';
+is $dom->at('input[name=t]')->val, '', 'right value';
+is $dom->at('input[name=u]')->val, undef, 'no value';
# PoCo example with whitespace sensitive text
$dom = DOM::Tiny->new(<<EOF);