Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
handle :first-* and :last-* separately
  • Loading branch information
kraih committed Nov 17, 2015
1 parent b660963 commit 804c89d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/Mojo/DOM/CSS.pm
Expand Up @@ -106,9 +106,11 @@ sub _compile {
# ":not" (contains more selectors)
$pc->[2] = _compile($args) if $name eq 'not';

# ":first-*" or ":last-*" (rewrite to ":nth-*")
@$pc[1, 2] = $1 ? ("nth-$2", [0, 1]) : ("nth-last-$2", [-1, 1])
if $name =~ /^(?:(first)|last)-(.+)$/;
# ":first-*" (rewrite to ":nth-*")
@$pc[1, 2] = ("nth-$1", [0, 1]) if $name =~ /^first-(.+)$/;

# ":last-*" (rewrite to ":nth-*")
@$pc[1, 2] = ("nth-$name", [-1, 1]) if $name =~ /^last-/;

# "nth-*" (with An+B notation)
$pc->[2] = _equation($args) if $name =~ /^nth-/;
Expand Down

0 comments on commit 804c89d

Please sign in to comment.