DOM58/_CSS.pm

filter: Statementstmt 98.4% 260 / 264 Branchbran 94.6% 229 / 242 Conditioncond 85.9% 104 / 121 MC/DCmcdc 77.7% 56 / 72 Subroutinesub 96.8% 31 / 32 Podpod 0.0% 0 / 5 totaltotal 92.3% 680 / 736 CC 176 SCAR 28.3
CC
176
Cov
95%
_pc
35.0
_compile
33.0
_step_back
17.2
CRAP 16.9
« DOM58/_HTML.pm ↑ Summary DOM58/Entities.pm »
1 package Mojo::DOM58::_CSS;
2  
3 # This file is part of Mojo::DOM58 which is released under:
4 # The Artistic License 2.0 (GPL Compatible)
5 # See the documentation for Mojo::DOM58 for full license details.
6  
7 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Data::Dumper ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶use constant DEBUG => $ENV{MOJO_DOM58_CSS_DEBUG} || 0;
Subroutine BEGIN: called CC=2 SCAR=7.1
Condition50%1/2
$ENV{'MOJO_DOM58_CSS_DEBUG'} || 0
l!l
02
MC/DC0%0/1
$ENV{'MOJO_DOM58_CSS_DEBUG'} || 0
$ENV{'MOJO_DOM58_CSS_DEBUG'}
Truth table50%1/2
A
A= $ENV{'MOJO_DOM58_CSS_DEBUG'}
Aresult
11
00
13  
14 2 our $VERSION = '3.003';
15  
16 2 my $ESCAPE_RE = qr/\\[^0-9a-fA-F]|\\[0-9a-fA-F]{1,6}/;
17 2 my $ATTR_RE = qr/
18 \[
19 ((?:$ESCAPE_RE|[\w\-])+) # Key
20 (?:
21 (\W)?= # Operator
22 (?:"((?:\\"|[^"])*)"|'((?:\\'|[^'])*)'|([^\]]+?)) # Value
23 (?:\s+(?:(i|I)|s|S))? # Case-sensitivity
24 )?
25 \]
26 /x;
27  
28 1208 ▶sub new {
Subroutine new: called CC=4 SCAR=17.9
Pod undocumented
29 1208 my $class = shift;
30 0 ▶ bless @_ ? @_ > 1 ? {@_} : {%{$_[0]}} : {}, ref $class || $class;
Branch: 2 branches
BranchTrueFalseTotal
@_ ? : 1208 0 1208
@_ > 1 ? : 1208 0 1208
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
012080
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
31 }
32  
33 1208 ▶sub tree {
Subroutine tree: called CC=2 SCAR=9.2
Pod undocumented
34 1208 my $self = shift;
35 1208 ▶ return $self->{tree} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 1208 0 1208
36 0 $self->{tree} = shift;
37 0 return $self;
38 }
39  
40 51 ▶sub matches {
Subroutine matches: called CC=2 SCAR=6.9
Pod undocumented
41 51 my $tree = shift->tree;
42 51 ▶ return undef if $tree->[0] ne 'tag';
Branch: 1 branch
BranchTrueFalseTotal
if $tree->[0] ne "tag" 2 49 51
43 49 return _match(_compile(@_), $tree, $tree, _root($tree));
44 }
45  
46 445 ▶sub select { _select(0, shift->tree, _compile(@_)) }
Subroutine select: called CC=1 SCAR=0.0
Pod undocumented
47 712 ▶sub select_one { _select(1, shift->tree, _compile(@_)) }
Subroutine select_one: called CC=1 SCAR=0.0
Pod undocumented
48  
49 45 ▶sub _absolutize { [map { _is_scoped($_) ? $_ : [[['pc', 'scope']], ' ', @$_] } @{shift()}] }
Subroutine _absolutize: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
_is_scoped($_) ? : 45 3 48
50  
51 1761 ▶sub _all_tags {
Subroutine _all_tags: called CC=4 SCAR=13.9
52 1761 my $tree = shift;
53  
54 1761 my @tags;
55 1761 ▶ my @queue = @$tree[($tree->[0] eq 'root' ? 1 : 4) .. $#$tree];
Branch: 1 branch
BranchTrueFalseTotal
$tree->[0] eq 'root' ? : 667 1094 1761
56 1761 ▶ while (my $current = shift @queue) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $current = shift @queue) 136372 1761 138133
57 136372 ▶ next unless $current->[0] eq 'tag';
Branch: 1 branch
BranchTrueFalseTotal
unless $current->[0] eq "tag" 90431 45941 136372
58 45941 push @tags, $current;
59 45941 unshift @queue, @$current[4 .. $#$current];
60 }
61  
62 1761 return \@tags;
63 }
64  
65 1645 ▶sub _attr {
Subroutine _attr: called CC=6 SCAR=17.9
66 1645 my ($name, $value_re, $current) = @_;
67  
68 1645 my $attrs = $current->[2];
69 1645 ▶ return undef unless exists $attrs->{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $attrs->{$name} 991 654 1645
70  
71 654 my $value = $attrs->{$name};
72 654 ▶ return undef if !defined $value && defined $value_re;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $value and defined $value_re 1 653 654
Condition100%3/3
not defined $value and defined $value_re
!ll&&!rl&&r
643101
MC/DC100%2/2
not defined $value and defined $value_re
not defined $value defined $value_re
Truth table100%3/3
not(A) and B
A= not defined $valueB= defined $value_re
ABresult
0X0
100
111
73 653 ▶ return 1 if !defined $value_re || $value =~ $value_re;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $value_re or $value =~ /$value_re/ 407 246 653
Condition100%3/3
not defined $value_re or $value =~ /$value_re/
l!l&&r!l&&!r
36371246
MC/DC100%2/2
not defined $value_re or $value =~ /$value_re/
not defined $value_re $value =~ /$value_re/
Truth table100%3/3
not(A) or B
A= not defined $value_reB= $value =~ /$value_re/
ABresult
1X1
011
000
74  
75 246 return undef;
76 }
77  
78 1262 ▶sub _compile {
Subroutine _compile: called CC=33 SCAR=35.0
79 1262 my ($css, %ns) = ('' . shift, @_);
80 1262 $css =~ s/^\s+//;
81 1262 $css =~ s/\s+$//;
82  
83 1262 my $group = [[]];
84 1262 ▶ while (my $selectors = $group->[-1]) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $selectors = $group->[-1]) 4392 0 4392
85 4392 ▶ push @$selectors, [] unless @$selectors && ref $selectors->[-1];
Branch: 1 branch
BranchTrueFalseTotal
unless @$selectors and ref $selectors->[-1] 2026 2366 4392
Condition100%3/3
@$selectors and ref $selectors->[-1]
!ll&&!rl&&r
12797472366
MC/DC100%2/2
@$selectors and ref $selectors->[-1]
@$selectors ref $selectors->[-1]
Truth table100%3/3
A and B
A= @$selectorsB= ref $selectors->[-1]
ABresult
0X0
100
111
86 4392 my $last = $selectors->[-1];
87  
88 # Separator
89 4392 ▶ if ($css =~ /\G\s*,\s*/gc) { push @$group, [] }
Branch: 7 branches
BranchTrueFalseTotal
if ($css =~ /\G\s*,\s*/cg) { } 17 4375 4392
elsif ($css =~ /\G\s*([>+~])\s*/cg) { } 485 3890 4375
elsif ($css =~ /\G\s+/cg) { } 262 3628 3890
elsif ($css =~ /\G([.#])((?:$ESCAPE_RE\s?|[^,.#:[\s>~+])+)/cog) { } 160 3468 3628
elsif ($css =~ /\G$ATTR_RE/cog) { } 250 3218 3468
elsif ($css =~ /\G:([\w\-]+)(?:\(((?:\([^)]+\)|[^)])+)\))?/cgs) { } 299 2919 3218
elsif ($css =~ /\G((?:$ESCAPE_RE\s|\\[\s\S]|[^,.#:[\s>~+])+)/cog) { } 1658 1261 2919
90  
91 # Combinator
92 elsif ($css =~ /\G\s*([>+~])\s*/gc) {
93 485 ▶ push @$last, ['pc', 'scope'] unless @$last;
Branch: 1 branch
BranchTrueFalseTotal
unless @$last 11 474 485
94 485 push @$selectors, $1;
95 }
96  
97 # Descendent combinator
98 elsif ($css =~ /\G\s+/gc) {
99 262 ▶ push @$last, ['pc', 'scope'] unless @$last;
Branch: 1 branch
BranchTrueFalseTotal
unless @$last 0 262 262
100 262 push @$selectors, ' ';
101 }
102  
103 # Class or ID
104 elsif ($css =~ /\G([.#])((?:$ESCAPE_RE\s?|[^,.#:[\s>~+])+)/gco) {
105 160 ▶ my ($name, $op) = $1 eq '.' ? ('class', '~') : ('id', '');
Branch: 1 branch
BranchTrueFalseTotal
$1 eq '.' ? : 49 111 160
106 160 push @$last, ['attr', $name, _value($op, $2)];
107 }
108  
109 # Attributes
110 elsif ($css =~ /\G$ATTR_RE/gco) {
111 250 ▶ push @$last, [
Branch: 3 branches
BranchTrueFalseTotal
defined $2 ? : 108 142 250
defined $3 ? : 111 139 250
defined $4 ? : 2 137 139
112 'attr', _unescape($1),
113 _value(
114 defined($2) ? $2 : '',
115 defined($3) ? $3 : defined($4) ? $4 : $5,
116 $6
117 ),
118 ];
119 }
120  
121 # Pseudo-class
122 elsif ($css =~ /\G:([\w\-]+)(?:\(((?:\([^)]+\)|[^)])+)\))?/gcs) {
123 299 my ($name, $args) = (lc $1, $2);
124  
125 # ":text" (raw text)
126 299 ▶ $args = [$args =~ m!^/(.+)/$! ? qr/$1/ : qr/\Q$args\E/i] if $name eq 'text';
Branch: 2 branches
BranchTrueFalseTotal
if $name eq "text" 21 278 299
$args =~ m[^/(.+)/$] ? : 6 15 21
127  
128 # ":is" and ":not" (contains more selectors)
129 299 ▶ $args = _compile($args, %ns) if $name eq 'has' || $name eq 'is' || $name eq 'not';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "has" or $name eq "is" or $name eq "not" 56 243 299
Condition100%6/6
$name eq "has" or $name eq "is" or $name eq "not"
l!l&&r!l&&!r
1145243
$name eq "has" or $name eq "is"
l!l&&r!l&&!r
65288
MC/DC100%3/3
$name eq "has" or $name eq "is" or $name eq "not"
$name eq "has" $name eq "is" $name eq "not"
Truth table100%4/4
A or B or C
A= $name eq "has"B= $name eq "is"C= $name eq "not"
ABCresult
1XX1
01X1
0011
0000
130  
131 # ":nth-*" (with An+B notation)
132 299 ▶ $args = _equation($args) if $name =~ /^nth-/;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /^nth-/ 117 182 299
133  
134 # ":first-*", ":last-*" (rewrite to ":nth-(last-)*")
135 299 ▶ ($name, $args) = ("nth-$+", [0, 1]) if $name =~ /^(?:first-(.+)|(last-.+))$/;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /^(?:first-(.+)|(last-.+))$/ 24 275 299
136  
137 299 push @$last, ['pc', $name, $args];
138 }
139  
140 # Tag
141 elsif ($css =~ /\G((?:$ESCAPE_RE\s|\\[\s\S]|[^,.#:[\s>~+])+)/gco) {
142 1658 ▶ my $alias = (my $name = $1) =~ s/^([^|]*)\|// && $1 ne '*' ? $1 : undef;
Branch: 1 branch
BranchTrueFalseTotal
(my $name = $1) =~ s/^([^|]*)\|// && $1 ne '*' ? : 69 1589 1658
Condition100%3/3
(my $name = $1) =~ s/^([^|]*)\|// and $1 ne "*"
!ll&&!rl&&r
1588169
MC/DC100%2/2
(my $name = $1) =~ s/^([^|]*)\|// and $1 ne "*"
(my $name = $1) =~ s/^([^|]*)\|// $1 ne "*"
Truth table100%3/3
A and B
A= (my $name = $1) =~ s/^([^|]*)\|//B= $1 ne "*"
ABresult
0X0
100
111
143 1658 ▶ return [['invalid']] if defined $alias && length $alias && !defined $ns{$alias};
Branch: 1 branch
BranchTrueFalseTotal
if defined $alias and length $alias and not defined $ns{$alias} 1 1657 1658
Condition100%6/6
defined $alias and length $alias and not defined $ns{$alias}
!ll&&!rl&&r
1593641
defined $alias and length $alias
!ll&&!rl&&r
1589465
MC/DC100%3/3
defined $alias and length $alias and not defined $ns{$alias}
defined $alias length $alias not defined $ns{$alias}
Truth table100%4/4
A and B and not(C)
A= defined $aliasB= length $aliasC= not defined $ns{$alias}
ABCresult
0XX0
10X0
1100
1111
144 1657 ▶ my $ns = defined $alias && length $alias ? $ns{$alias} : $alias;
Branch: 1 branch
BranchTrueFalseTotal
defined $alias && length $alias ? : 64 1593 1657
Condition100%3/3
defined $alias and length $alias
!ll&&!rl&&r
1589464
MC/DC100%2/2
defined $alias and length $alias
defined $alias length $alias
Truth table100%3/3
A and B
A= defined $aliasB= length $alias
ABresult
0X0
100
111
145 1657 ▶ push @$last, ['tag', $name eq '*' ? undef : _name($name), _unescape($ns)];
Branch: 1 branch
BranchTrueFalseTotal
$name eq '*' ? : 45 1612 1657
146 }
147  
148 1261 ▶ else { pos $css < length $css ? croak "Unknown CSS selector: $css" : last }
Branch: 1 branch
BranchTrueFalseTotal
pos $css < length $css ? : 2 1259 1261
149 }
150  
151 1259 warn qq{-- CSS Selector ($css)\n@{[_dumper($group)]}} if DEBUG;
152 1259 return $group;
153 }
154  
155 0 ▶sub _dumper { Data::Dumper->new([@_])->Indent(1)->Sortkeys(1)->Terse(1)->Useqq(1)->Dump }
Subroutine _dumper: not called CC=1 SCAR=6.9
156  
157 117 ▶sub _equation {
Subroutine _equation: called CC=9 SCAR=22.0
158 117 ▶ return [0, 0] unless my $equation = shift;
Branch: 1 branch
BranchTrueFalseTotal
unless my $equation = shift() 2 115 117
159  
160 # "even"
161 115 ▶ return [2, 0] if $equation =~ /^\s*even\s*$/i;
Branch: 1 branch
BranchTrueFalseTotal
if $equation =~ /^\s*even\s*$/i 9 106 115
162  
163 # "odd"
164 106 ▶ return [2, 1] if $equation =~ /^\s*odd\s*$/i;
Branch: 1 branch
BranchTrueFalseTotal
if $equation =~ /^\s*odd\s*$/i 12 94 106
165  
166 # "4", "+4" or "-4"
167 94 ▶ return [0, $1] if $equation =~ /^\s*((?:\+|-)?\d+)\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
if $equation =~ /^\s*((?:\+|-)?\d+)\s*$/ 42 52 94
168  
169 # "n", "4n", "+4n", "-4n", "n+1", "4n-1", "+4n-1" (and other variations)
170 52 ▶ return [0, 0]
Branch: 1 branch
BranchTrueFalseTotal
unless $equation =~ /^\s*((?:\+|-)?(?:\d+)?)?n\s*((?:\+|-)\s*\d+)?\s*$/i 1 51 52
171 unless $equation =~ /^\s*((?:\+|-)?(?:\d+)?)?n\s*((?:\+|-)\s*\d+)?\s*$/i;
172 51 ▶ return [$1 eq '-' ? -1 : !length $1 ? 1 : $1, join('', split(' ', $2 || 0))];
Branch: 2 branches
BranchTrueFalseTotal
$1 eq '-' ? : 18 33 51
!length($1) ? : 6 27 33
Condition100%2/2
$2 || 0
l!l
429
MC/DC100%1/1
$2 || 0
$2
Truth table100%2/2
A
A= $2
Aresult
11
00
173 }
174  
175 677 ▶sub _evaluate {
Subroutine _evaluate: called CC=2 SCAR=6.9
176 677 my ($group, $tree, $scope, $pool) = @_;
177  
178 677 my (@results, %seen);
179 677 push @results, grep { !$seen{$_}++ } _evaluate_one($_, $tree, $scope, $pool) for @$group;
180  
181 677 return \@results;
182 }
183  
184 688 ▶sub _evaluate_one {
Subroutine _evaluate_one: called CC=8 SCAR=20.8
185 688 my ($selector, $tree, $scope, $pool) = @_;
186  
187 # Match the leftmost compound, then propagate forward through combinators
188 688 my @parts = @$selector;
189 688 my $compound = shift @parts;
190 688 ▶ return () unless ref $compound;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $compound 1 687 688
191 687 my @candidates = grep { _selector($compound, $_, $tree, $scope) } @$pool;
192  
193 687 ▶ while (@parts) {
Branch: 1 branch
BranchTrueFalseTotal
if (@parts) 750 687 1437
194 750 my $combinator = shift @parts;
195 750 my $next = shift @parts;
196 750 ▶ return () unless ref $next;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $next 0 750 750
197  
198 750 my (%seen, @new);
199 750 for my $node (@candidates) {
200 1729 for my $cand (_step_forward($combinator, $node)) {
201 40998 ▶ next if $seen{$cand}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$cand}++ 37649 3349 40998
202 3349 ▶ push @new, $cand if _selector($next, $cand, $tree, $scope);
Branch: 1 branch
BranchTrueFalseTotal
if _selector($next, $cand, $tree, $scope) 1812 1537 3349
203 }
204 }
205 750 @candidates = @new;
206 }
207  
208 687 return @candidates;
209 }
210  
211 1302 ▶sub _is_scoped {
Subroutine _is_scoped: called CC=8 SCAR=20.8
212 1302 my $selector = shift;
213  
214 1302 ▶ for my $pc (grep { $_->[0] eq 'pc' } map { ref $_ ? @$_ : () } @$selector) {
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 2100 800 2900
215  
216 # Selector with ":scope"
217 361 ▶ return 1 if $pc->[1] eq 'scope';
Branch: 1 branch
BranchTrueFalseTotal
if $pc->[1] eq "scope" 90 271 361
218  
219 # Argument of functional pseudo-class with ":scope"
220 271 ▶ return 1 if ($pc->[1] eq 'has' || $pc->[1] eq 'is' || $pc->[1] eq 'not') && grep { _is_scoped($_) } @{$pc->[2]};
Branch: 1 branch
BranchTrueFalseTotal
if $pc->[1] eq "has" || $pc->[1] eq "is" || $pc->[1] eq "not" and grep {_is_scoped($_);} @{$$pc[2];} 10 261 271
Condition100%9/9
$pc->[1] eq "has" || $pc->[1] eq "is" || $pc->[1] eq "not" and grep {_is_scoped($_);} @{$$pc[2];}
!ll&&!rl&&r
2085310
$pc->[1] eq "has" or $pc->[1] eq "is" or $pc->[1] eq "not"
l!l&&r!l&&!r
1548208
$pc->[1] eq "has" or $pc->[1] eq "is"
l!l&&r!l&&!r
96256
MC/DC100%4/4
$pc->[1] eq "has" || $pc->[1] eq "is" || $pc->[1] eq "not" and grep {_is_scoped($_);} @{$$pc[2];}
$pc->[1] eq "has" $pc->[1] eq "is" $pc->[1] eq "not" grep {_is_scoped($_);} @{$$pc[2];}
Truth table100%7/7
A or B or C and D
A= $pc->[1] eq "has"B= $pc->[1] eq "is"C= $pc->[1] eq "not"D= grep {_is_scoped($_);} @{$$pc[2];}
ABCDresult
000X0
1XX00
01X00
00100
1XX11
01X11
00111
221 }
222  
223 1202 return undef;
224 }
225  
226 157 ▶sub _match {
Subroutine _match: called CC=3 SCAR=11.0
227 157 my ($group, $current, $tree, $scope) = @_;
228 157 ▶ _match_one($_, $current, $tree, $scope) and return 1 for @$group;
Branch: 1 branch
BranchTrueFalseTotal
_match_one($_, $current, $tree, $scope) and return 1 64 103 167
229 93 return undef;
230 }
231  
232 167 ▶sub _match_one {
Subroutine _match_one: called CC=10 SCAR=23.1
233 167 my ($selector, $current, $tree, $scope) = @_;
234  
235 # Match the rightmost compound, then propagate backward through combinators
236 167 my @parts = reverse @$selector;
237 167 my $compound = shift @parts;
238 167 ▶ return undef unless ref $compound && _selector($compound, $current, $tree, $scope);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $compound and _selector($compound, $current, $tree, $scope) 101 66 167
Condition66%2/3
ref $compound and _selector($compound, $current, $tree, $scope)
!ll&&!rl&&r
010166
MC/DC50%1/2
ref $compound and _selector($compound, $current, $tree, $scope)
ref $compound _selector($compound, $current, $tree, $scope)
Truth table66%2/3
A and B
A= ref $compoundB= _selector($compound, $current, $tree, $scope)
ABresult
0X0
100
111
239  
240 66 my @candidates = ($current);
241 66 ▶ while (@parts) {
Branch: 1 branch
BranchTrueFalseTotal
if (@parts) 6 64 70
242 6 my $combinator = shift @parts;
243 6 my $next = shift @parts;
244 6 ▶ return undef unless ref $next;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $next 0 6 6
245  
246 6 my (%seen, @new);
247 6 for my $node (@candidates) {
248 6 for my $cand (_step_back($combinator, $node, $scope)) {
249 9 ▶ next if $seen{$cand}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$cand}++ 0 9 9
250 9 ▶ push @new, $cand if _selector($next, $cand, $tree, $scope);
Branch: 1 branch
BranchTrueFalseTotal
if _selector($next, $cand, $tree, $scope) 4 5 9
251 }
252 }
253 6 ▶ return undef unless @new;
Branch: 1 branch
BranchTrueFalseTotal
unless @new 2 4 6
254 4 @candidates = @new;
255 }
256  
257 64 return 1;
258 }
259  
260 1612 ▶sub _name {qr/(?:^|:)\Q@{[_unescape(shift)]}\E$/}
Subroutine _name: called CC=1 SCAR=0.0
261  
262 77 ▶sub _namespace {
Subroutine _namespace: called CC=5 SCAR=16.1
263 77 my ($ns, $current) = @_;
264  
265 77 ▶ my $attr = $current->[1] =~ /^([^:]+):/ ? "xmlns:$1" : 'xmlns';
Branch: 1 branch
BranchTrueFalseTotal
$current->[1] =~ /^([^:]+):/ ? : 4 73 77
266 77 ▶ while ($current) {
Branch: 1 branch
BranchTrueFalseTotal
if ($current) 119 0 119
267 119 ▶ last if $current->[0] eq 'root';
Branch: 1 branch
BranchTrueFalseTotal
if $current->[0] eq "root" 4 115 119
268 115 ▶ return $current->[2]{$attr} eq $ns if exists $current->[2]{$attr};
Branch: 1 branch
BranchTrueFalseTotal
if exists $current->[2]{$attr} 73 42 115
269  
270 42 $current = $current->[3];
271 }
272  
273 # Failing to match yields true if searching for no namespace, false otherwise
274 4 return !length $ns;
275 }
276  
277 1836 ▶sub _pc {
Subroutine _pc: called CC=35 SCAR=35.6
278 1836 my ($class, $args, $current, $tree, $scope) = @_;
279  
280 # ":scope" (root can only be a :scope)
281 1836 ▶ return $current eq $scope if $class eq 'scope';
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "scope" 494 1342 1836
282 1342 ▶ return undef if $current->[0] eq 'root';
Branch: 1 branch
BranchTrueFalseTotal
if $current->[0] eq "root" 26 1316 1342
283  
284 # ":checked"
285 return exists $current->[2]{checked} || exists $current->[2]{selected}
286 1316 ▶ if $class eq 'checked';
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "checked" 195 1121 1316
Condition100%3/3
exists $current->[2]{'checked'} || exists $current->[2]{'selected'}
l!l&&r!l&&!r
2138136
MC/DC100%2/2
exists $current->[2]{'checked'} || exists $current->[2]{'selected'}
exists $current->[2]{'checked'} exists $current->[2]{'selected'}
Truth table100%3/3
A || B
A= exists $current->[2]{'checked'}B= exists $current->[2]{'selected'}
ABresult
1X1
011
000
287  
288 # ":not"
289 1121 ▶ return !_match($args, $current, $current, $scope) if $class eq 'not';
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "not" 95 1026 1121
290  
291 # ":is"
292 1026 ▶ return !!_match($args, $current, $current, $scope) if $class eq 'is';
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "is" 13 1013 1026
293  
294 # ":has"
295 1013 ▶ return !!_select(1, $current, $args) if $class eq 'has';
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "has" 19 994 1013
296  
297 # ":empty"
298 994 ▶ return !grep { !($_->[0] eq 'comment' || $_->[0] eq 'pi') } @$current[4 .. $#$current] if $class eq 'empty';
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "empty" 28 966 994
Condition100%3/3
$_->[0] eq 'comment' || $_->[0] eq 'pi'
l!l&&r!l&&!r
2254
MC/DC100%2/2
$_->[0] eq 'comment' || $_->[0] eq 'pi'
$_->[0] eq 'comment' $_->[0] eq 'pi'
Truth table100%3/3
A || B
A= $_->[0] eq 'comment'B= $_->[0] eq 'pi'
ABresult
1X1
011
000
299  
300 # ":root"
301 966 ▶ return $current->[3] && $current->[3][0] eq 'root' if $class eq 'root';
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "root" 52 914 966
Condition66%2/3
$current->[3] && $current->[3][0] eq 'root'
!ll&&!rl&&r
0448
MC/DC50%1/2
$current->[3] && $current->[3][0] eq 'root'
$current->[3] $current->[3][0] eq 'root'
Truth table66%2/3
A && B
A= $current->[3]B= $current->[3][0] eq 'root'
ABresult
0X0
100
111
302  
303 # ":text"
304 914 ▶ return grep { ($_->[0] eq 'text' || $_->[0] eq 'raw') && $_->[1] =~ $args->[0] } @$current[4 .. $#$current]
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "text" 78 836 914
Condition83%5/6
($_->[0] eq 'text' || $_->[0] eq 'raw') && $_->[1] =~ /$args->[0]/
!ll&&!rl&&r
6612816
$_->[0] eq "text" or $_->[0] eq "raw"
l!l&&r!l&&!r
144066
MC/DC66%2/3
($_->[0] eq 'text' || $_->[0] eq 'raw') && $_->[1] =~ /$args->[0]/
$_->[0] eq "text" $_->[0] eq "raw" $_->[1] =~ /$args->[0]/
Truth table60%3/5
A or B && C
A= $_->[0] eq "text"B= $_->[0] eq "raw"C= $_->[1] =~ /$args->[0]/
ABCresult
00X0
1X00
0100
1X11
0111
305 if $class eq 'text';
306  
307 # ":any-link", ":link" and ":visited"
308 836 ▶ if ($class eq 'any-link' || $class eq 'link' || $class eq 'visited') {
Branch: 1 branch
BranchTrueFalseTotal
if ($class eq "any-link" or $class eq "link" or $class eq "visited") 39 797 836
Condition100%6/6
$class eq "any-link" or $class eq "link" or $class eq "visited"
l!l&&r!l&&!r
2613797
$class eq "any-link" or $class eq "link"
l!l&&r!l&&!r
1313810
MC/DC100%3/3
$class eq "any-link" or $class eq "link" or $class eq "visited"
$class eq "any-link" $class eq "link" $class eq "visited"
Truth table100%4/4
A or B or C
A= $class eq "any-link"B= $class eq "link"C= $class eq "visited"
ABCresult
1XX1
01X1
0011
0000
309 39 ▶ return undef unless $current->[0] eq 'tag' && exists $current->[2]{href};
Branch: 1 branch
BranchTrueFalseTotal
unless $current->[0] eq "tag" and exists $current->[2]{"href"} 18 21 39
Condition66%2/3
$current->[0] eq "tag" and exists $current->[2]{"href"}
!ll&&!rl&&r
01821
MC/DC50%1/2
$current->[0] eq "tag" and exists $current->[2]{"href"}
$current->[0] eq "tag" exists $current->[2]{"href"}
Truth table66%2/3
A and B
A= $current->[0] eq "tag"B= exists $current->[2]{"href"}
ABresult
0X0
100
111
310 21 return !!grep { $current->[1] eq $_ } qw(a area link);
311 }
312  
313 # ":only-child" or ":only-of-type"
314 797 ▶ if ($class eq 'only-child' || $class eq 'only-of-type') {
Branch: 1 branch
BranchTrueFalseTotal
if ($class eq "only-child" or $class eq "only-of-type") 26 771 797
Condition100%3/3
$class eq "only-child" or $class eq "only-of-type"
l!l&&r!l&&!r
206771
MC/DC100%2/2
$class eq "only-child" or $class eq "only-of-type"
$class eq "only-child" $class eq "only-of-type"
Truth table100%3/3
A or B
A= $class eq "only-child"B= $class eq "only-of-type"
ABresult
1X1
011
000
315 26 ▶ my $type = $class eq 'only-of-type' ? $current->[1] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$class eq 'only-of-type' ? : 6 20 26
316 26 ▶ $_ ne $current and return undef for @{_siblings($current, $type)};
Branch: 1 branch
BranchTrueFalseTotal
$_ ne $current and return undef 20 10 30
317 6 return 1;
318 }
319  
320 # ":nth-child", ":nth-last-child", ":nth-of-type" or ":nth-last-of-type"
321 771 ▶ if (ref $args) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args) 763 8 771
322 763 ▶ my $type = $class eq 'nth-of-type'
Branch: 1 branch
BranchTrueFalseTotal
$class eq 'nth-of-type' || $class eq 'nth-last-of-type' ? : 68 695 763
Condition100%3/3
$class eq "nth-of-type" or $class eq "nth-last-of-type"
l!l&&r!l&&!r
2741695
MC/DC100%2/2
$class eq "nth-of-type" or $class eq "nth-last-of-type"
$class eq "nth-of-type" $class eq "nth-last-of-type"
Truth table100%3/3
A or B
A= $class eq "nth-of-type"B= $class eq "nth-last-of-type"
ABresult
1X1
011
000
323 || $class eq 'nth-last-of-type' ? $current->[1] : undef;
324 763 my @siblings = @{_siblings($current, $type)};
325 763 my $index;
326 763 for my $i (0 .. $#siblings) {
327 3204 ▶ $index = $i, last if $siblings[$i] eq $current;
Branch: 1 branch
BranchTrueFalseTotal
if $siblings[$i] eq $current 763 2441 3204
328 }
329 763 ▶ $index = $#siblings - $index if $class eq 'nth-last-child' || $class eq 'nth-last-of-type';
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "nth-last-child" or $class eq "nth-last-of-type" 233 530 763
Condition100%3/3
$class eq "nth-last-child" or $class eq "nth-last-of-type"
l!l&&r!l&&!r
19241530
MC/DC100%2/2
$class eq "nth-last-child" or $class eq "nth-last-of-type"
$class eq "nth-last-child" $class eq "nth-last-of-type"
Truth table100%3/3
A or B
A= $class eq "nth-last-child"B= $class eq "nth-last-of-type"
ABresult
1X1
011
000
330 763 $index++;
331  
332 763 my $delta = $index - $args->[1];
333 763 ▶ return 1 if $delta == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $delta == 0 117 646 763
334 646 ▶ return $args->[0] != 0 && ($delta < 0) == ($args->[0] < 0) && $delta % $args->[0] == 0;
Condition100%6/6
$args->[0] != 0 && $delta < 0 == $args->[0] < 0 && $delta % $args->[0] == 0
!ll&&!rl&&r
301156189
$args->[0] != 0 and $delta < 0 == $args->[0] < 0
!ll&&!rl&&r
189112345
MC/DC100%3/3
$args->[0] != 0 && $delta < 0 == $args->[0] < 0 && $delta % $args->[0] == 0
$args->[0] != 0 $delta < 0 == $args->[0] < 0 $delta % $args->[0] == 0
Truth table100%4/4
A and B && C
A= $args->[0] != 0B= $delta < 0 == $args->[0] < 0C= $delta % $args->[0] == 0
ABCresult
0XX0
10X0
1100
1111
335 }
336  
337 # Everything else
338 8 return undef;
339 }
340  
341 94 ▶sub _root {
Subroutine _root: called CC=2 SCAR=6.9
342 94 my $tree = shift;
343 94 ▶ $tree = $tree->[3] while $tree->[0] ne 'root';
Branch: 1 branch
BranchTrueFalseTotal
$tree->[0] ne "root" and do { $tree = $tree->[3] } 163 94 257
344 94 return $tree;
345 }
346  
347 1174 ▶sub _select {
Subroutine _select: called CC=13 SCAR=25.6
348 1174 my ($one, $scope, $group) = @_;
349  
350 # Scoped selectors require the whole tree to be searched
351 1174 my $tree = $scope;
352 1174 ▶ ($group, $tree) = (_absolutize($group), _root($scope)) if grep { _is_scoped($_) } @$group;
Branch: 1 branch
BranchTrueFalseTotal
if grep {_is_scoped($_);} @$group 45 1129 1174
353  
354 # Without combinators the first match in document order can be returned right away
355 1174 ▶ if ($one && !grep { @$_ != 1 || !ref $_->[0] } @$group) {
Branch: 1 branch
BranchTrueFalseTotal
if ($one and not grep({@$_ != 1 or not ref $_->[0];} @$group)) 497 677 1174
Condition100%6/6
$one and not grep({@$_ != 1 or not ref $_->[0];} @$group)
!ll&&!rl&&r
444233497
@$_ != 1 || !ref($_->[0])
l!l&&r!l&&!r
2351499
MC/DC100%2/2
$one and not grep({@$_ != 1 or not ref $_->[0];} @$group)
$one not grep({@$_ != 1 or not ref $_->[0];} @$group)
MC/DC100%2/2
@$_ != 1 || !ref($_->[0])
@$_ != 1 !ref($_->[0])
Truth table100%3/3
A and not(B)
A= $oneB= not grep({@$_ != 1 or not ref $_->[0];} @$group)
ABresult
0X0
100
111
Truth table100%3/3
A || not(B)
A= @$_ != 1B= !ref($_->[0])
ABresult
1X1
011
000
356 497 ▶ my @queue = @$tree[($tree->[0] eq 'root' ? 1 : 4) .. $#$tree];
Branch: 1 branch
BranchTrueFalseTotal
$tree->[0] eq 'root' ? : 467 30 497
357 497 ▶ while (my $current = shift @queue) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $current = shift @queue) 2822 49 2871
358 2822 ▶ next unless $current->[0] eq 'tag';
Branch: 1 branch
BranchTrueFalseTotal
unless $current->[0] eq "tag" 1492 1330 2822
359 1330 ▶ return $current if grep { _selector($_->[0], $current, $tree, $scope) } @$group;
Branch: 1 branch
BranchTrueFalseTotal
if grep {_selector($_->[0], $current, $tree, $scope);} @$group 448 882 1330
360 882 unshift @queue, @$current[4 .. $#$current];
361 }
362 49 return undef;
363 }
364  
365 # Pool includes $tree so ":scope" can match it, but results exclude it
366 677 my $tags = _all_tags($tree);
367 677 my %match = map { $_ => 1 } @{_evaluate($group, $tree, $scope, [$tree, @$tags])};
368  
369 677 my @results;
370 677 for my $node (@$tags) {
371 5696 ▶ next unless $match{$node};
Branch: 1 branch
BranchTrueFalseTotal
unless $match{$node} 4451 1245 5696
372 1245 ▶ return $node if $one;
Branch: 1 branch
BranchTrueFalseTotal
if $one 207 1038 1245
373 1038 push @results, $node;
374 }
375  
376 470 ▶ return $one ? undef : \@results;
Branch: 1 branch
BranchTrueFalseTotal
$one ? : 26 444 470
377 }
378  
379 11820 ▶sub _selector {
Subroutine _selector: called CC=13 SCAR=25.6
380 11820 my ($selector, $current, $tree, $scope) = @_;
381  
382 # The root might be the scope
383 11820 my $is_tag = $current->[0] eq 'tag';
384 11820 for my $s (@$selector) {
385 12877 my $type = $s->[0];
386  
387 # Tag
388 12877 ▶ if ($is_tag && $type eq 'tag') {
Branch: 3 branches
BranchTrueFalseTotal
if ($is_tag and $type eq 'tag') { } 8785 4092 12877
elsif ($is_tag and $type eq 'attr') { } 1645 2447 4092
elsif ($type eq 'pc') { } 1836 611 2447
Condition100%3/3
$is_tag and $type eq "tag"
!ll&&!rl&&r
67634168785
MC/DC100%2/2
$is_tag and $type eq "tag"
$is_tag $type eq "tag"
Truth table100%3/3
A and B
A= $is_tagB= $type eq "tag"
ABresult
0X0
100
111
389 8785 ▶ return undef if defined $s->[1] && $current->[1] !~ $s->[1];
Branch: 1 branch
BranchTrueFalseTotal
if defined $s->[1] and not $current->[1] =~ /$s->[1]/ 5101 3684 8785
Condition100%3/3
defined $s->[1] and not $current->[1] =~ /$s->[1]/
!ll&&!rl&&r
87828065101
MC/DC100%2/2
defined $s->[1] and not $current->[1] =~ /$s->[1]/
defined $s->[1] not $current->[1] =~ /$s->[1]/
Truth table100%3/3
A and not(B)
A= defined $s->[1]B= not $current->[1] =~ /$s->[1]/
ABresult
0X0
100
111
390 3684 ▶ return undef if defined $s->[2] && !_namespace($s->[2], $current);
Branch: 1 branch
BranchTrueFalseTotal
if defined $s->[2] and not _namespace($s->[2], $current) 16 3668 3684
Condition100%3/3
defined $s->[2] and not _namespace($s->[2], $current)
!ll&&!rl&&r
36076116
MC/DC100%2/2
defined $s->[2] and not _namespace($s->[2], $current)
defined $s->[2] not _namespace($s->[2], $current)
Truth table100%3/3
A and not(B)
A= defined $s->[2]B= not _namespace($s->[2], $current)
ABresult
0X0
100
111
391 }
392  
393 # Attribute
394 1645 ▶ elsif ($is_tag && $type eq 'attr') { return undef unless _attr(@$s[1, 2], $current) }
Branch: 1 branch
BranchTrueFalseTotal
unless _attr(@$s[1, 2], $current) 1238 407 1645
Condition100%3/3
$is_tag and $type eq "attr"
!ll&&!rl&&r
67617711645
MC/DC100%2/2
$is_tag and $type eq "attr"
$is_tag $type eq "attr"
Truth table100%3/3
A and B
A= $is_tagB= $type eq "attr"
ABresult
0X0
100
111
395  
396 # Pseudo-class
397 1836 ▶ elsif ($type eq 'pc') { return undef unless _pc(@$s[1, 2], $current, $tree, $scope) }
Branch: 1 branch
BranchTrueFalseTotal
unless _pc(@$s[1, 2], $current, $tree, $scope) 1295 541 1836
398  
399 # No match
400 611 else { return undef }
401 }
402  
403 3559 return 1;
404 }
405  
406 892 ▶sub _siblings {
Subroutine _siblings: called CC=3 SCAR=11.0
407 892 my ($current, $type) = @_;
408  
409 892 my $parent = $current->[3];
410 892 ▶ my @siblings = grep { $_->[0] eq 'tag' }
Branch: 1 branch
BranchTrueFalseTotal
$parent->[0] eq 'root' ? : 97 795 892
411 @$parent[($parent->[0] eq 'root' ? 1 : 4) .. $#$parent];
412 892 ▶ @siblings = grep { $type eq $_->[1] } @siblings if defined $type;
Branch: 1 branch
BranchTrueFalseTotal
if defined $type 74 818 892
413  
414 892 return \@siblings;
415 }
416  
417 6 ▶sub _step_back {
Subroutine _step_back: called CC=13 SCAR=28.5
418 6 my ($combinator, $node, $scope) = @_;
419  
420 # " " (ancestors) and ">" (parent only)
421 6 ▶ if ($combinator eq ' ' || $combinator eq '>') {
Branch: 1 branch
BranchTrueFalseTotal
if ($combinator eq " " or $combinator eq ">") 2 4 6
Condition66%2/3
$combinator eq " " or $combinator eq ">"
l!l&&r!l&&!r
024
MC/DC50%1/2
$combinator eq " " or $combinator eq ">"
$combinator eq " " $combinator eq ">"
Truth table66%2/3
A or B
A= $combinator eq " "B= $combinator eq ">"
ABresult
1X1
011
000
422 2 my @ancestors;
423 2 ▶ while ($node ne $scope && $node->[0] ne 'root' && ($node = $node->[3])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node ne $scope and $node->[0] ne "root" and $node = $node->[3]) 2 0 2
Condition33%2/6
$node ne $scope and $node->[0] ne "root" and $node = $node->[3]
!ll&&!rl&&r
002
$node ne $scope and $node->[0] ne "root"
!ll&&!rl&&r
002
MC/DC0%0/3
$node ne $scope and $node->[0] ne "root" and $node = $node->[3]
$node ne $scope $node->[0] ne "root" $node = $node->[3]
Truth table25%1/4
A and B and C
A= $node ne $scopeB= $node->[0] ne "root"C= $node = $node->[3]
ABCresult
0XX0
10X0
1100
1111
424 2 push @ancestors, $node;
425 2 ▶ last if $combinator eq '>' || $node eq $scope;
Branch: 1 branch
BranchTrueFalseTotal
if $combinator eq ">" or $node eq $scope 2 0 2
Condition33%1/3
$combinator eq ">" or $node eq $scope
l!l&&r!l&&!r
200
MC/DC0%0/2
$combinator eq ">" or $node eq $scope
$combinator eq ">" $node eq $scope
Truth table33%1/3
A or B
A= $combinator eq ">"B= $node eq $scope
ABresult
1X1
011
000
426 }
427 2 return @ancestors;
428 }
429  
430 # "~" (preceding siblings) and "+" (immediately preceding)
431 4 ▶ return () if $node->[0] eq 'root';
Branch: 1 branch
BranchTrueFalseTotal
if $node->[0] eq "root" 0 4 4
432 4 my @prev;
433 4 for my $sib (@{_siblings($node)}) {
434 14 ▶ last if $sib eq $node;
Branch: 1 branch
BranchTrueFalseTotal
if $sib eq $node 4 10 14
435 10 push @prev, $sib;
436 }
437 4 ▶ return $combinator eq '+' ? ($prev[-1] || ()) : @prev;
Branch: 1 branch
BranchTrueFalseTotal
$combinator eq '+' ? : 2 2 4
Condition33%1/3
$prev[-1] or ()
l!l&&r!l&&!r
200
MC/DC0%0/2
$prev[-1] or ()
$prev[-1] ()
Truth table33%1/3
A or B
A= $prev[-1]B= ()
ABresult
1X1
011
000
438 }
439  
440 1729 ▶sub _step_forward {
Subroutine _step_forward: called CC=10 SCAR=23.1
441 1729 my ($combinator, $node) = @_;
442  
443 # " " (descendants)
444 1729 ▶ return @{_all_tags($node)} if $combinator eq ' ';
Branch: 1 branch
BranchTrueFalseTotal
if $combinator eq " " 1084 645 1729
445  
446 # ">" (children only)
447 645 ▶ return grep { $_->[0] eq 'tag' } @$node[($node->[0] eq 'root' ? 1 : 4) .. $#$node] if $combinator eq '>';
Branch: 2 branches
BranchTrueFalseTotal
if $combinator eq ">" 546 99 645
$node->[0] eq 'root' ? : 3 543 546
448  
449 # "~" (following siblings) and "+" (immediately following)
450 99 ▶ return () if $node->[0] eq 'root';
Branch: 1 branch
BranchTrueFalseTotal
if $node->[0] eq "root" 0 99 99
451 99 my (@next, $found);
452 99 for my $sib (@{_siblings($node)}) {
453 405 ▶ push @next, $sib if $found;
Branch: 1 branch
BranchTrueFalseTotal
if $found 175 230 405
454 405 ▶ $found = 1 if $sib eq $node;
Branch: 1 branch
BranchTrueFalseTotal
if $sib eq $node 99 306 405
455 }
456 99 ▶ return $combinator eq '+' ? ($next[0] || ()) : @next;
Branch: 1 branch
BranchTrueFalseTotal
$combinator eq '+' ? : 47 52 99
Condition66%2/3
$next[0] or ()
l!l&&r!l&&!r
4403
MC/DC50%1/2
$next[0] or ()
$next[0] ()
Truth table66%2/3
A or B
A= $next[0]B= ()
ABresult
1X1
011
000
457 }
458  
459 3885 ▶sub _unescape {
Subroutine _unescape: called CC=2 SCAR=6.9
460 3885 ▶ return undef unless defined(my $value = shift);
Branch: 1 branch
BranchTrueFalseTotal
unless defined(my $value = shift()) 1589 2296 3885
461  
462 # Remove escaped newlines
463 2296 $value =~ s/\\\n//g;
464  
465 # Unescape Unicode characters
466 2296 $value =~ s/\\([0-9a-fA-F]{1,6})\s?/pack 'U', hex $1/ge;
467  
468 # Remove backslash
469 2296 $value =~ s/\\//g;
470  
471 2296 return $value;
472 }
473  
474 410 ▶sub _value {
Subroutine _value: called CC=8 SCAR=20.8
475 410 my ($op, $value, $insensitive) = @_;
476 410 ▶ return undef unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 44 366 410
477 366 ▶ $value = ($insensitive ? '(?i)' : '') . quotemeta _unescape($value);
Branch: 1 branch
BranchTrueFalseTotal
$insensitive ? : 10 356 366
478  
479 # "~=" (word)
480 366 ▶ return qr/(?:^|\s+)$value(?:\s+|$)/ if $op eq '~';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "~" 72 294 366
481  
482 # "|=" (hyphen-separated)
483 294 ▶ return qr/^$value(?:-|$)/ if $op eq '|';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "|" 10 284 294
484  
485 # "*=" (contains)
486 284 ▶ return qr/$value/ if $op eq '*';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "*" 12 272 284
487  
488 # "^=" (begins with)
489 272 ▶ return qr/^$value/ if $op eq '^';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "^" 32 240 272
490  
491 # "$=" (ends with)
492 240 ▶ return qr/$value$/ if $op eq '$';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "\$" 31 209 240
493  
494 # Everything else
495 209 return qr/^$value$/;
496 }
497  
498 2 1;
499  
500 =for Pod::Coverage *EVERYTHING*
501  
502 =cut
« DOM58/_HTML.pm ↑ Summary DOM58/Entities.pm »