Created
February 10, 2012 13:21
-
-
Save sharifulin/1789638 to your computer and use it in GitHub Desktop.
Mojo::DOM bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use lib 'lib'; | |
use Mojo::DOM; | |
use Test::More tests => 9; | |
my $dom = Mojo::DOM->new('<div> <ul> <li> Text <ul> <li>abc </li>def </ul> </li> </ul> </div>'); | |
my $find; | |
# Error | |
$find = $dom->find('div > ul > li'); | |
is $find->size, 1, 'right number of elements'; | |
is $find->[0], '<li> Text <ul> <li>abc </li>def </ul> </li>', 'right text'; | |
is $find->[1], undef, 'no result'; | |
# Try another | |
$find = $dom->find('div > ul')->[0]->children('li'); | |
is $find->size, 1, 'right number of elements'; | |
is $find->[0], '<li> Text <ul> <li>abc </li>def </ul> </li>', 'right text'; | |
is $find->[1], undef, 'no result'; | |
# Ok | |
$find = $dom->find('div > ul li'); | |
is $find->size, 2, 'right number of elements'; | |
is $find->[0], '<li> Text <ul> <li>abc </li>def </ul> </li>', 'right text'; | |
is $find->[1], '<li>abc </li>', 'right text'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment