Skip to content

Commit 4248bbe

Browse files
committed
fix
1 parent cbbf6b7 commit 4248bbe

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,13 +2175,13 @@ $collection->each(sub {
21752175
### map
21762176

21772177
```perl
2178-
my $result = $collection->map(sub {
2178+
my $new_collection = $collection->map(sub {
21792179
my ($token, $index) = @_;
21802180
return "FOUND: ".$node->tag." => $index";
21812181
});
21822182

21832183
# Also can bypass additional arguments
2184-
my $result = $collection->map(sub {
2184+
my $new_collection = $collection->map(sub {
21852185
my ($token, $index, $title) = @_;
21862186
return $title.$node->tag." => $index";
21872187
}, "FOUND: ");
@@ -2190,7 +2190,7 @@ my $result = $collection->map(sub {
21902190
Apply callback for each node in collection. Returns new array from results.
21912191

21922192
```perl
2193-
my $result = $collection->map($method, @args);
2193+
my $new_collection = $collection->map($method, @args);
21942194
```
21952195

21962196
Call method for each node in collection. Returns new [HTML5::DOM::Collection](#html5domcollection) from results.
@@ -2199,10 +2199,10 @@ Example:
21992199

22002200
```perl
22012201
# set text 'test!' for all nodes
2202-
my $result = $collection->map('text', 'test!');
2202+
$collection->map('text', 'test!');
22032203

22042204
# get all tag names as array
2205-
my $result = $collection->map('tag');
2205+
my $new_collection = $collection->map('tag');
22062206

22072207
# remove all nodes in collection
22082208
$collection->map('remove');
@@ -2240,14 +2240,14 @@ print $collection->length; # 3
22402240
### grep
22412241

22422242
```perl
2243-
my $node = $collection->grep(qr/regexp/);
2243+
my $new_collection = $collection->grep(qr/regexp/);
22442244
```
22452245

22462246
Evaluates regexp for html code of each element in collection and creates new collection with all matched elements.
22472247

22482248
```perl
2249-
my $node = $collection->grep(sub {...});
2250-
my $node = $collection->grep(sub {...}, @args);
2249+
my $new_collection = $collection->grep(sub {...});
2250+
my $new_collection = $collection->grep(sub {...}, @args);
22512251
```
22522252

22532253
Evaluates callback foreach element in collection and creates new collection with all elements for which callback returned true.
@@ -2448,7 +2448,7 @@ print join(', ', @{$collection->head(2)->map('text')}; # Linux, OSX
24482448
### tail
24492449
24502450
```perl
2451-
my $new_collection = $collection->head($length);
2451+
my $new_collection = $collection->tail($length);
24522452
```
24532453
24542454
Returns copy of collection with only last `$length` items.

lib/HTML5/DOM.pod

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,30 +2044,30 @@ Example:
20442044

20452045
=head3 map
20462046

2047-
my $result = $collection->map(sub {
2047+
my $new_collection = $collection->map(sub {
20482048
my ($token, $index) = @_;
20492049
return "FOUND: ".$node->tag." => $index";
20502050
});
20512051

20522052
# Also can bypass additional arguments
2053-
my $result = $collection->map(sub {
2053+
my $new_collection = $collection->map(sub {
20542054
my ($token, $index, $title) = @_;
20552055
return $title.$node->tag." => $index";
20562056
}, "FOUND: ");
20572057

20582058
Apply callback for each node in collection. Returns new array from results.
20592059

2060-
my $result = $collection->map($method, @args);
2060+
my $new_collection = $collection->map($method, @args);
20612061

20622062
Call method for each node in collection. Returns new L<HTML5::DOM::Collection|/HTML5::DOM::Collection> from results.
20632063

20642064
Example:
20652065

20662066
# set text 'test!' for all nodes
2067-
my $result = $collection->map('text', 'test!');
2067+
$collection->map('text', 'test!');
20682068

20692069
# get all tag names as array
2070-
my $result = $collection->map('tag');
2070+
my $new_collection = $collection->map('tag');
20712071

20722072
# remove all nodes in collection
20732073
$collection->map('remove');
@@ -2097,12 +2097,12 @@ Items count in collection.
20972097

20982098
=head3 grep
20992099

2100-
my $node = $collection->grep(qr/regexp/);
2100+
my $new_collection = $collection->grep(qr/regexp/);
21012101

21022102
Evaluates regexp for html code of each element in collection and creates new collection with all matched elements.
21032103

2104-
my $node = $collection->grep(sub {...});
2105-
my $node = $collection->grep(sub {...}, @args);
2104+
my $new_collection = $collection->grep(sub {...});
2105+
my $new_collection = $collection->grep(sub {...}, @args);
21062106

21072107
Evaluates callback foreach element in collection and creates new collection with all elements for which callback returned true.
21082108

@@ -2267,7 +2267,7 @@ Returns copy of collection with only first C<$length> items.
22672267

22682268
=head3 tail
22692269

2270-
my $new_collection = $collection->head($length);
2270+
my $new_collection = $collection->tail($length);
22712271

22722272
Returns copy of collection with only last C<$length> items.
22732273

lib/HTML5/DOM/Collection.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ sub length { scalar(@{shift()}); }
2626
sub first {
2727
my ($self, $callback) = (shift, shift);
2828
return $self->[0] if (!$callback);
29-
return List::Util::first { $_ =~ $callback } @$self if (_is_regexp $callback);
29+
return List::Util::first { $_ =~ $callback } @$self if (_is_regexp($callback));
3030
return List::Util::first { $_->$callback(@_) } @$self;
3131
}
3232

@@ -90,7 +90,7 @@ sub uniq {
9090

9191
sub grep {
9292
my ($self, $callback) = (shift, shift);
93-
return HTML5::DOM::Collection->new([grep { $_ =~ $callback } @$self]) if (_is_regexp $callback);
93+
return HTML5::DOM::Collection->new([grep { $_ =~ $callback } @$self]) if (_is_regexp($callback));
9494
return HTML5::DOM::Collection->new([grep { $_->$callback(@_) } @$self]);
9595
}
9696

0 commit comments

Comments
 (0)