Skip to content

Instantly share code, notes, and snippets.

@sharifulin
Created February 10, 2012 13:21
Show Gist options
  • Save sharifulin/1789638 to your computer and use it in GitHub Desktop.
Save sharifulin/1789638 to your computer and use it in GitHub Desktop.
Mojo::DOM bug
#!/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