Changeset 8552

Show
Ignore:
Timestamp:
03/31/08 11:24:53 (8 months ago)
Author:
tokuhirom
Message:

lang/perl/HTML-Selector-XPath: added *:last-child support

Location:
lang/perl/HTML-Selector-XPath/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/HTML-Selector-XPath/trunk/lib/HTML/Selector/XPath.pm

    r1286 r8552  
    114114            if ( $1 eq 'first-child') { 
    115115                $parts[$#parts] = '*[1]/self::' . $parts[$#parts]; 
     116            } elsif ( $1 eq 'last-child') { 
     117                push @parts, '[not(following-sibling::*)]'; 
    116118            } elsif ($1 =~ /^lang\(([\w\-]+)\)$/) { 
    117119                push @parts, "[\@xml:lang='$1' or starts-with(\@xml:lang, '$1-')]"; 
  • lang/perl/HTML-Selector-XPath/trunk/t/01_xpath.t

    r1284 r8552  
    126126--- xpath 
    127127//E[count(preceding-sibling::*) = 0] 
     128 
     129=== 
     130--- selector 
     131E:last-child 
     132--- xpath 
     133//E[not(following-sibling::*)] 
     134 
     135 
     136=== 
     137--- selector 
     138F E:last-child 
     139--- xpath 
     140//F//E[not(following-sibling::*)] 
     141 
     142=== 
     143--- selector 
     144F > E:last-child 
     145--- xpath 
     146//F/E[not(following-sibling::*)] 
     147