Changeset 370

Show
Ignore:
Timestamp:
05/30/08 05:34:23 (4 months ago)
Author:
ingy
Message:
v0.07
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/ingy/pQuery/Changes

    r356 r370  
     1--- 
     2version: 0.07 
     3date:    Fri May 30 05:31:03 PDT 2008 
     4changes: 
     5- Fixed some bugs reported by Simon Cozens. 
     6  https://rt.cpan.org/Ticket/Display.html?id=36104 
     7- Fixed https://rt.cpan.org/Ticket/Display.html?id=34890 
     8 
    19--- 
    210version: 0.06 
  • trunk/src/ingy/pQuery/README

    r356 r370  
    130130    Returns the version number of the pQuery module. 
    131131 
    132     =size() 
    133  
     132  size() 
    134133    Returns the number of elements in the pQuery object. 
    135134 
    136     =length() 
    137  
     135  length() 
    138136    Also returns the number of elements in the pQuery object. 
    139137 
  • trunk/src/ingy/pQuery/lib/pQuery.pm

    r363 r370  
    1010use base 'Exporter'; 
    1111 
    12 our $VERSION = '0.06'; 
     12our $VERSION = '0.07'; 
    1313 
    1414our $document; 
     
    6969        if ($match and ($1 or not $context)) { 
    7070            if ($1) { 
    71                 $selector = [pQuery::DOM->fromHTML($1)]; 
     71                my $html = $this->_clean($1); 
     72                $selector = [pQuery::DOM->fromHTML($html)]; 
    7273#                 $selector = $this->_clean([$1], $context); 
    7374            } 
     
    9495                my $html = do {local $/; <FILE>}; 
    9596                close FILE; 
    96                 $html =~ s/^\s*<!DOCTYPE\s.*?>\s*//s
     97                $html = $this->_clean($html)
    9798                $selector = [$document = pQuery::DOM->fromHTML($html)]; 
    9899            } 
     
    107108        : $selector; 
    108109    return $this; 
     110} 
     111 
     112sub _clean { 
     113    my ($this, $html) = @_; 
     114    $html =~ s/^\s*<\?xml\s.*?>\s*//s; 
     115    $html =~ s/^\s*<!DOCTYPE\s.*?>\s*//s; 
     116    return $html; 
    109117} 
    110118 
     
    685693 
    686694            for (my ($i, $rl) = (0, scalar(@$r)); $i < $rl; $i++) { 
    687                 my ($a, $z) = ($r->[$i], $this->_props->[$m->[2]] || $m->[2]); 
     695                my $a = $r->[$i]; 
     696                my $z = $a->{($this->_props->{$m->[2]} || $m->[2])}; 
    688697 
    689698                if (not defined $z or $m->[2] =~ /href|src|selected/) { 
     
    692701 
    693702                if ( 
    694                     ( 
     703                    (( 
    695704                        $type eq "" and $z or 
    696705                        $type eq "=" and $z eq $m->[5] or 
     
    700709                        ($type eq "*=" or $type eq "~=") and 
    701710                            index($z, $m->[5]) >= 0 
    702                     ) ^ $not 
     711                    ) ? 1 : 0) ^ ($not ? 1 : 0) 
    703712                ) { push @$tmp, $a } 
    704713            } 
     
    750759} 
    751760 
     761sub _props { 
     762    return { 
     763        for => "htmlFor", 
     764        class => "className", 
     765#         float => styleFloat, 
     766#         cssFloat => styleFloat, 
     767#         styleFloat => styleFloat, 
     768        innerHTML => "innerHTML", 
     769        className => "className", 
     770        value => "value", 
     771        disabled => "disabled", 
     772        checked => "checked", 
     773        readonly => "readOnly",  
     774        selected => "selected", 
     775        maxlength => "maxLength", 
     776        selectedIndex => "selectedIndex", 
     777        defaultValue => "defaultValue", 
     778        tagName => "tagName", 
     779        nodeName => "nodeName" 
     780    }; 
     781} 
     782 
    752783################################################################################ 
    753784# These methods need to go down here because they are Perl builtins. 
     
    10031034Returns the version number of the pQuery module. 
    10041035 
    1005 =size() 
     1036=head2 size() 
    10061037 
    10071038Returns the number of elements in the pQuery object. 
    10081039 
    1009 =length() 
     1040=head2 length() 
    10101041 
    10111042Also returns the number of elements in the pQuery object. 
  • trunk/src/ingy/pQuery/t/contructors.t

    r356 r370  
    5252is ref($pQuery), 'pQuery::DOM', '$pQuery is a DOM'; 
    5353is $pq->find('title')->text, 'Sample HTML Document', 'Document is correct'; 
    54  
    55