Skip to content

Commit

Permalink
keep Mojo::DOM::val deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Dec 7, 2014
1 parent 09a549a commit a5801d5
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 69 deletions.
1 change: 0 additions & 1 deletion Changes
Expand Up @@ -2,7 +2,6 @@
5.69 2014-12-08
- Removed deprecated emit_safe method from Mojo::EventEmitter.
- Removed deprecated render_static method from Mojolicious::Controller.
- Reverted deprecation of Mojo::DOM::val.
- Improved Mojo::DOM::HTML performance slightly.
- Fixed parent combinator bug in Mojo::DOM::CSS.
- Fixed whitespace bug in Mojo::DOM::HTML.
Expand Down
27 changes: 2 additions & 25 deletions lib/Mojo/DOM.pm
Expand Up @@ -180,7 +180,9 @@ sub type {
return $self;
}

# DEPRECATED in Tiger Face!
sub val {
deprecated 'Mojo::DOM::val is DEPRECATED';
my $self = shift;

# "option"
Expand Down Expand Up @@ -864,31 +866,6 @@ This element's type.
# List types of child elements
say $dom->children->map('type')->join("\n");
=head2 val
my $collection = $dom->val;
Extract values from C<button>, C<input>, C<option>, C<select> or C<textarea>
element and return a L<Mojo::Collection> object containing these values. In
the case of C<select>, find all C<option> elements it contains that have a
C<selected> attribute and extract their values.
# "b"
$dom->parse('<input name="a" value="b">')->at('input')->val->first;
# "d"
$dom->parse('<textarea name="c">d</textarea>')->at('[name=c]')->val->first;
# "e"
$dom->parse('<option value="e">Test</option>')->at('option')->val->first;
# "f"
$dom->parse('<option>f</option>')->at('option')->val->first;
# "g"
$dom->parse('<select><option selected>g</option></select>')
->at('select')->val->first;
=head2 wrap
$dom = $dom->wrap('<div></div>');
Expand Down
2 changes: 1 addition & 1 deletion lib/Test/Mojo.pm
Expand Up @@ -662,7 +662,7 @@ arguments as L<Mojo::UserAgent/"get">, except for the callback.
# Run additional tests on the transaction
$t->get_ok('/foo')->status_is(200);
is $t->tx->res->dom->at('input')->val->first, 'whatever', 'right value';
is $t->tx->res->dom->at('input')->{value}, 'whatever', 'right value';
=head2 head_ok
Expand Down
41 changes: 0 additions & 41 deletions t/mojo/dom.t
Expand Up @@ -2287,47 +2287,6 @@ is $dom->find('div > ul li')->[2], undef, 'no result';
is $dom->find('div > ul ul')->[0]->text, 'C', 'right text';
is $dom->find('div > ul ul')->[1], undef, 'no result';

# Form values
$dom = Mojo::DOM->new(<<EOF);
<form action="/foo">
<p>Test</p>
<input type="text" name="a" value="A" />
<input type="checkbox" checked name="b" value="B">
<input type="radio" checked name="c" value="C">
<select name="f">
<option value="F">G</option>
<optgroup>
<option>H</option>
<option selected>I</option>
</optgroup>
<option value="J" selected>K</option>
</select>
<select name="n"><option>N</option></select>
<select name="d"><option selected>D</option></select>
<textarea name="m">M</textarea>
<button name="o" value="O">No!</button>
<input type="submit" name="p" value="P" />
</form>
EOF
is_deeply [$dom->at('p')->val->each], [], 'no values';
is $dom->at('input')->val->size, 1, 'one value';
is $dom->at('input')->val->first, 'A', 'right value';
is $dom->at('input:checked')->val->first, 'B', 'right value';
is $dom->at('input:checked[type=radio]')->val->first, 'C', 'right value';
is $dom->find('select')->first->val->join(':'), 'I:J', 'right value';
is_deeply [$dom->find('select')->first->val->each], ['I', 'J'], 'right values';
is $dom->at('select option')->val->size, 1, 'one value';
is $dom->at('select option')->val->first, 'F', 'right value';
is $dom->at('select optgroup option:not([selected])')->val->first, 'H',
'right value';
is $dom->find('select')->[1]->val->size, 0, 'no values';
is $dom->find('select')->[1]->at('option')->val->first, 'N', 'right value';
is $dom->find('select')->last->val->first, 'D', 'right value';
is $dom->at('textarea')->val->size, 1, 'one value';
is $dom->at('textarea')->val->first, 'M', 'right value';
is $dom->at('button')->val->first, 'O', 'right value';
is $dom->find('form input')->last->val->first, 'P', 'right value';

# Slash between attributes
$dom = Mojo::DOM->new('<input /type=checkbox / value="/a/" checked/><br/>');
is_deeply $dom->at('input')->attr,
Expand Down
2 changes: 1 addition & 1 deletion t/pod_coverage.t
Expand Up @@ -8,6 +8,6 @@ plan skip_all => 'Test::Pod::Coverage 1.04 required for this test!'
unless eval 'use Test::Pod::Coverage 1.04; 1';

# DEPRECATED in Tiger Face!
my @tiger = qw(decode encode error has_conditions new pluck);
my @tiger = qw(decode encode error has_conditions new pluck val);

all_pod_coverage_ok({also_private => [@tiger]});

0 comments on commit a5801d5

Please sign in to comment.