Subject: | querying by one of className, minus-character in id/class attribute |
1) There is not possible use minus-character (-) in id/class attribute
2) There is not possible use multiple classes separated by space in
class attribute (this is in jQuery possible).
I fix this 2 bugs, patch is attached.
Tomas Pokorny
Subject: | HTML-Query-0.02.tar.gz |
Message body not shown because it is not plain text.
Subject: | HTML-Query-0.01-0.02.patch |
diff -r HTML-Query-0.01/lib/HTML/Query.pm HTML-Query-0.02/lib/HTML/Query.pm
4c4
< version => 0.01,
---
> version => 0.02,
162c162
< if ($query =~ / \G \# (\w+) /cgx) {
---
> if ($query =~ / \G \# ([\w-]+) /cgx) {
167,168c167,168
< if ($query =~ / \G \. (\w+) /cgx) {
< push( @args, class => $1 );
---
> if ($query =~ / \G \. ([\w-]+) /cgx) {
> push( @args, class => qr/(^|\s)$1(\s|$)/ );
diff -r HTML-Query-0.01/Makefile.PL HTML-Query-0.02/Makefile.PL
8c8
< 'VERSION' => '0.01',
---
> 'VERSION' => '0.02',
diff -r HTML-Query-0.01/META.yml HTML-Query-0.02/META.yml
3c3
< version: 0.01
---
> version: 0.02
diff -r HTML-Query-0.01/t/html/test1.html HTML-Query-0.02/t/html/test1.html
18c18
< <div class="bar">
---
> <div class="bar new-class">
21c21
< <span class="bar">This is a span with bar class</span>
---
> <span class="new-class bar">This is a span with bar class</span>
37c37
< <tr class="wobble">
---
> <tr class="wobble new-class another-class">
54a55,57
> <div id="test-id" class="new-class">
> test-id content
> </div>
56c59
< </html>
\ No newline at end of file
---
> </html>
diff -r HTML-Query-0.01/t/query.t HTML-Query-0.02/t/query.t
17c17
< tests => 48,
---
> tests => 55,
190a191,204
> #-----------------------------------------------------------------------
> # check id/class with minus-character
> #-----------------------------------------------------------------------
>
> my @found = $query->query('#test-id');
> is( scalar(@found), 1, 'found elemnt with id "test-id"' );
> is( $found[0]->as_trimmed_text, 'test-id content', 'got right element' );
>
> @found = $query->query('.new-class');
> is( scalar(@found), 4, 'found all elements with class "new-class"' );
> is( $found[0]->as_trimmed_text, 'This is another div with bar class', 'got right 1st element' );
> is( $found[1]->as_trimmed_text, 'This is a span with bar class', 'got right 2nd element' );
> is( $found[2]->as_trimmed_text, 'Wobble1', 'got right 3rd element' );
> is( $found[3]->as_trimmed_text, 'test-id content', 'got right 4th element' );