Skip to content

Commit

Permalink
test more variants
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 13, 2015
1 parent 7900fdd commit 5626f1b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Mojo/DOM/CSS.pm
Expand Up @@ -128,7 +128,7 @@ sub _equation {
# "4", "+4" or "-4"
return [0, $1] if $equation =~ /^\s*((?:\+|-)?\d+)\s*$/;

# "4n", "+4n", "-4n", "4n+1" or "4n-1"
# "n", "4n", "+4n", "-4n", "n+1" or "4n-1"
return []
unless $equation =~ /^\s*((?:\+|-)?(?:\d+)?)?n\s*((?:\+|-)\s*\d+)?\s*$/i;
return [$1 eq '-' ? -1 : $1 eq '' ? 1 : $1, join('', split(' ', $2 // 0))];
Expand Down
6 changes: 6 additions & 0 deletions t/mojo/dom.t
Expand Up @@ -1042,6 +1042,12 @@ is_deeply \@li, [qw(A B C D E F G)], 'found first three li elements';
$dom->find('li:nth-child(n+0)')->each(sub { push @li, shift->text });
is_deeply \@li, [qw(A B C D E F G)], 'found first three li elements';
@li = ();
$dom->find('li:nth-child(n)')->each(sub { push @li, shift->text });
is_deeply \@li, [qw(A B C D E F G)], 'found first three li elements';
@li = ();
$dom->find('li:nth-child(n+0)')->each(sub { push @li, shift->text });
is_deeply \@li, [qw(A B C D E F G)], 'found first three li elements';
@li = ();
$dom->find('li:NTH-CHILD(N+0)')->each(sub { push @li, shift->text });
is_deeply \@li, [qw(A B C D E F G)], 'found first three li elements';
@li = ();
Expand Down

0 comments on commit 5626f1b

Please sign in to comment.