Changeset 358

Show
Ignore:
Timestamp:
04/30/08 21:47:01 (2 weeks ago)
Author:
ingy
Message:
Make getElementsByTagName('*') work correctly.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/ingy/pQuery/lib/pQuery/DOM.pm

    r356 r358  
    160160    my $found = []; 
    161161    _find($self, $found, sub { $_->{_tag} eq $tag or $tag eq "*" }); 
     162    shift @$found if @$found and $found->[0] == $self; 
    162163    return $found; 
    163164} 
  • trunk/src/ingy/pQuery/t/dom.t

    r355 r358  
    1 use t::TestpQuery tests => 33
     1use t::TestpQuery tests => 35
    22 
     3use pQuery; 
    34use pQuery::DOM; 
    45 
     
    8384is $div->toHTML, '<div id="new-div" class="classy">Foo<!--I am remarkable--></div>', 
    8485        'createElement, createComment and appendChild work'; 
     86 
     87my $body = pQuery('t/document1.html')->find('body')->get(0); 
     88my $star = $body->getElementsByTagName('*'); 
     89is scalar(@$star), 10, 'Find all nodes'; 
     90is $star->[0]->tagName, 'H2', '* finds correct things'; 
     91 
  • trunk/src/ingy/pQuery/t/selectors.t

    r356 r358  
    55pQuery('t/spreadily.html'); 
    66 
     7# is pQuery('*')->size, 30, '* finds all'; 
     8# exit; 
    79is pQuery('h3')->text, 'The Intarweb is a Spreadsheet!', 
    810    'select an element by tag name';