Branch Coverage

blib/lib/HTML/Element.pm
Criterion Covered Total %
branch 354 752 47.0


line true false branch
31 24 0 if (@_)
33 0 24 if $using_weaken and not defined &Scalar::Util::weaken
37 24 0 $using_weaken ? :
55 1 0 if (/^-(no_?)?weak$/) { }
161 0 2149 unless defined $tag and length $tag
162 0 2149 if $tag =~ m[[<>/\x00-\x20]]
168 1 512 unless defined $val
171 310 1839 if ($tag eq 'html')
174 0 2149 if $self->{'_parent'}
182 5 3 if (@_) { }
183 4 1 if (defined $_[0]) { }
200 0 1022 if (@_) { }
211 0 118 if (@_) { }
212 0 0 if defined $_[0] and ref $_[0] and $self eq $_[0]
224 0 136 unless +(shift())->{'_content'}
225 28 1399 unless +(shift())->{'_content'}
136 1427 wantarray ? :
241 0 0 unless +(shift())->{'_content'}
253 0 0 if (@_)
255 0 0 if (defined $parm and $parm ne $self) { }
262 0 0 if defined $pos
285 6 2 length $_ && substr($_, 0, 1) eq '_' ? :
295 0 0 if (@_ == 1) { }
0 0 elsif (@_ == 2) { }
299 0 0 if (defined $_[1]) { }
313 0 0 unless (defined $HTML::Element::ID_COUNTER)
326 0 0 if ($nparms == 1)
328 0 0 if (defined($x = $_[0]{'id'}) and length $x) { }
335 0 0 if ($nparms == 2)
336 0 0 if (defined $_[1]) { }
349 1 3831 unless @_
353 3 3835 if (ref $_ eq 'ARRAY') { }
1605 2230 elsif (ref $_) { }
360 1 1604 if $_->{'_parent'}
365 386 1844 if (@$content and not ref $content->[-1]) { }
381 0 2 unless @_
385 1 1 if (ref $_ eq 'ARRAY') { }
1 0 elsif (ref $_) { }
392 0 1 if $_->{'_parent'}
397 0 0 if (@$content and not ref $content->[0]) { }
415 0 2 if @_ < 2
423 2 0 if (@_ > 2) { }
425 1 1 if (ref $n eq 'ARRAY') { }
1 0 elsif (ref $n) { }
440 4 0 if ref $n
448 3 1 unless my $parent = $self->{'_parent'}
462 4 1 if ref $_
471 0 4 unless my($parent) = $self->{'_parent'}
474 0 4 unless $parent_content and @$parent_content
479 0 8 if (not ref $_) { }
4 4 elsif ($_ eq $self) { }
0 4 elsif ($_ eq $parent) { }
2 2 elsif (ref $_ eq 'ARRAY') { }
486 0 4 if $replacers_contains_self++
503 4 24 ref $_ && $_ eq $self ? :
506 0 4 unless $replacers_contains_self
516 0 2 unless @_
523 0 2 unless @_
531 0 10 unless my($parent) = $self->{'_parent'}
534 0 10 unless $parent_content and @$parent_content
538 10 25 ref $_ && $_ eq $self ? :
544 0 0 if ref $_
553 0 1156 unless delete $_[0]{'_content'}
567 786 1186 if ref $_
580 1156 134 if $self->{'_content'} and @{$self->{'_content'};}
582 0 1286 if $self->{'_parent'} and $self->{'_parent'}{'_content'}
595 0 4 unless ref $it
597 0 4 if @_
603 3 1 if ($it->{'_content'} and @{$it->{'_content'};})
607 3 2 if ref $_
616 0 3 if ref shift @_
621 3 2 ref $_ ? :
632 0 1 unless $c = $start->{'_content'} and ref $c and @$c
641 1 5 if (defined $c->[$i] and ref $c->[$i]) { }
642 1 0 if ($stretches[0])
645 0 1 if ($stretches[0][1] == 1) { }
660 3 2 unless defined $c->[$i]
661 3 2 if ($stretches[0]) { }
675 2 2 if ($s and $s->[1] > 1)
704 0 278 unless ref $_[0]
707 0 278 if $HTML::Element::Debug > 2
711 1 1811 if (($ptag = +($this = shift @to_do)->{'_tag'}) eq 'pre' or $ptag eq 'textarea' or $HTML::Tagset::isCDATA_Parent{$ptag})
717 0 2 if $HTML::Element::Debug
720 150 1661 unless $sibs = $this->{'_content'} and @$sibs
722 1535 1702 if (ref $sibs->[$i])
729 1192 510 if $sibs->[$i] =~ /[^\n\r\f\t ]/s
732 0 510 if $HTML::Element::Debug > 3
737 2 508 if ($i == 0) { }
346 162 elsif ($i == $#$sibs) { }
738 2 0 if (@$sibs == 1) { }
739 0 2 unless $HTML::Element::canTighten{$ptag}
747 0 0 unless $HTML::Element::canTighten{$ptag} or ref $sibs->[1] and $HTML::Element::canTighten{$sibs->[1]{'_tag'}}
757 0 0 unless $HTML::Element::canTighten{$ptag} or ref $$sibs[$i - 1] and $HTML::Element::canTighten{$$sibs[$i - 1]{'_tag'}}
763 0 162 unless ref $$sibs[$i - 1] or ref $$sibs[$i + 1]
777 162 0 if ref $$sibs[$i - 1] and ref $$sibs[$i + 1] and not $HTML::Element::canTighten{$$sibs[$i - 1]{'_tag'}} and not $HTML::Element::canTighten{$$sibs[$i + 1]{'_tag'}}
783 0 348 if $HTML::Element::Debug > 3
798 0 1597 unless $tag
801 989 608 if (ref $tag) { }
807 608 0 if exists $self->{'_element_count'}
812 608 989 if $implicit
815 592 1005 unless defined $pos
820 1582 0 unless $self->_empty_element_map->{$tag} or $e->{'_empty_element'}
833 15 2689 if (wantarray) { }
843 0 0 if (wantarray) { }
861 0 0 unless defined $fh
862 0 0 unless defined $depth
864 0 0 $self->{'_implicit'} ? :
866 0 0 if (ref $_) { }
871 0 0 if (length $_ > 65 or /[\x00-\x1F]/) { }
874 0 0 length $_ <= 65 ? :
904 15 247 if (defined $indent and length $indent) { }
908 456 160 if (ref $node) { }
911 0 456 unless $node->can('starttag')
918 229 227 if ($start) { }
203 24 elsif (not $empty_element_map->{$tag} || $omissible_map->{$tag}) { }
919 164 65 if ($this_tag_tightenable = $HTML::Element::canTighten{$tag} and not $nonindentable_ancestors and $last_tag_tightenable) { }
940 1 227 if $tag eq 'pre' or $tag eq 'textarea' or $HTML::Tagset::isCDATA_Parent{$tag}
950 2 201 if ($tag eq 'pre' or $tag eq 'textarea' or $HTML::Tagset::isCDATA_Parent{$tag}) { }
960 89 112 if ($this_tag_tightenable = $HTML::Element::canTighten{$tag} and not $nonindentable_ancestors and $last_tag_tightenable) { }
993 160 0 unless defined $entities and not length $entities or $HTML::Tagset::isCDATA_Parent{$_[3]{'_tag'}} or $encoded_content
1001 0 160 if ($nonindentable_ancestors) { }
1005 0 160 if ($last_tag_tightenable) { }
1037 2385 1147 if (ref $node) { }
1040 0 2385 unless $node->isa($self->element_class)
1046 1195 1190 if ($start) { }
1172 18 elsif (not $empty_element_map->{$tag} || $omissible_map->{$tag}) { }
1069 1143 1 unless defined $entities and not length $entities or $HTML::Tagset::isCDATA_Parent{$_[3]{'_tag'}} or $encoded_content
1084 1 261 if ($self->{'_store_declarations'} and defined $self->{'_decl'})
1101 0 27 if (not defined $pile[0]) { }
12 15 elsif (not ref $pile[0]) { }
1108 1 14 unless $this->{'_content'}
1109 15 0 unless ($tag = +($this = shift @pile)->{'_tag'}) eq 'style' or $tag eq 'script' or $skip_dels and $tag eq 'del'
1122 3 4 defined $options{'extra_chars'} ? :
1148 1164 210 if (ref $node) { }
1150 589 575 if ($start) { }
1153 1 3679 unless $attr eq '/' or $self->_valid_name($attr)
1158 11 577 if ($empty_element_map->{$tag} and not @{$nillio unless $node->{'_content'};}) { }
1159 11 1 unless $node->{'_content'}
1168 575 0 unless ($empty_element_map->{$tag} and not @{$nillio unless $node->{'_content'};})
1169 0 1 unless $node->{'_content'}
1194 26 229 if ($encoded_content) { }
1233 0 1 unless defined $list[-1]
1237 1 1 if $_ eq '_content' or $_ eq '_tag' or $_ eq '_parent' or $_ eq '/'
1244 1 0 if defined($val = $self->{$_})
1254 0 1 unless $self->{'_content'}
1 0 if (@{$nillio unless $self->{'_content'};}) { }
1258 0 1 if (ref $c) { }
1292 0 0 unless (defined $formatter)
1306 0 1425 if $name eq '~literal'
1307 0 1425 if $name eq '~declaration'
1308 0 1425 if $name eq '~pi'
1310 0 1425 if ($name eq '~comment')
1311 0 0 if (ref($self->{'text'} || '') eq 'ARRAY') { }
1323 0 1425 $HTML::Element::html_uc ? :
1326 7640 487 if not length $_ or /^_/s or $_ eq '/'
1328 0 487 unless defined $val
1329 1 0 ref $HTML::Element::boolean_attr{$name} ? :
0 487 if ($_ eq $val and exists $HTML::Element::boolean_attr{$name} and ref $HTML::Element::boolean_attr{$name} ? $HTML::Element::boolean_attr{$name}{$_} : $HTML::Element::boolean_attr{$name} eq $_) { }
1337 0 0 $HTML::Element::html_uc ? :
1341 1 486 if (ref $val eq 'HTML::Element' and $val->{'_tag'} eq '~literal') { }
1347 486 0 unless defined $entities and not length $entities or $encoded_content
1356 0 487 $HTML::Element::html_uc ? :
1359 7 1418 if (scalar $self->content_list == 0 and $self->_empty_element_map->{$self->tag}) { }
1377 0 588 if $name eq '~literal'
1378 0 588 if $name eq '~declaration'
1379 0 588 if $name eq '~pi'
1381 1 587 if ($name eq '~comment')
1382 0 1 if (ref($self->{'text'} || '') eq 'ARRAY') { }
1397 3656 19 if not length $_ or /^_/s or $_ eq '/'
1401 0 19 unless defined($val = $self->{$_})
1405 10 577 @_ == 3 ? :
1410 0 1375 $HTML::Element::html_uc ? :
1448 0 380 unless ref $start
1451 0 380 unless defined $callback and ref $callback
1456 377 3 if (UNIVERSAL::isa($callback, 'CODE')) { }
3 0 elsif (UNIVERSAL::isa($callback, 'ARRAY')) { }
1461 0 3 if $c_pre and not UNIVERSAL::isa($c_pre, 'CODE')
1464 0 3 if $c_post and not UNIVERSAL::isa($c_post, 'CODE')
1467 0 3 unless $c_pre or $c_post
1472 0 0 unless ref $callback
1493 2376 3555 if (not defined $I[0] or ++$I[0] >= @{$C[0];})
1497 1992 384 if ($c_post and defined $I[0] and @C > 1 and defined($this = $C[1][$I[1]]) and ref $this and not $this->{'_empty_element'} || $$empty_element_map{$this->{'_tag'} or ''} && !@{$this->{'_content'};}) { }
1524 0 1992 if (defined $rv and ref $rv eq $travsignal_package)
1526 0 0 if ($rv eq 'ABORT') { }
0 0 elsif ($rv eq 'PRUNE') { }
0 0 elsif ($rv eq 'PRUNE_SOFTLY') { }
0 0 elsif ($rv eq 'OK') { }
0 0 elsif ($rv eq 'PRUNE_UP') { }
1560 3555 0 if ($c_pre)
1561 2030 1525 if (defined $this and ref $this) { }
1571 8 1517 if $ignore_text
1584 0 3546 if (not $rv) { }
3 3543 elsif (ref $rv eq $travsignal_package) { }
1589 3 0 if ($rv eq 'ABORT') { }
0 0 elsif ($rv eq 'PRUNE') { }
0 0 elsif ($rv eq 'PRUNE_SOFTLY') { }
0 0 elsif ($rv eq 'OK') { }
0 0 elsif ($rv eq 'PRUNE_UP') { }
1596 0 0 if (ref $this and not $this->{'_empty_element'} || $$empty_element_map{$this->{'_tag'} or ''})
1636 2008 1535 if (ref $this and not !(($content_r = $this->{'_content'}) && @$content_r) && ($this->{'_empty_element'} || $$empty_element_map{$this->{'_tag'} or ''}))
1660 0 2993 unless @_
1665 807 2186 if (scalar @_ == 1) { }
1667 319 678 if $current eq $_[0] or $current->{'_tag'} eq $_[0]
1674 0 5472 if $elements{$current} or $elements{$current->{'_tag'}}
1694 2 3 if ref $pc->[$i] and $pc->[$i] eq $self
1703 0 0 unless ref $_[0]
1708 0 0 unless @$pc
1709 0 0 if @$pc == 1
1711 0 0 if (wantarray) { }
1714 0 0 if ref $j and $j eq $_[0]
1720 0 0 $i ? :
0 0 if ref $pc->[$i] and $pc->[$i] eq $_[0]
1731 0 0 unless ref $_[0]
1736 0 0 unless @$pc
1737 0 0 if @$pc == 1
1739 0 0 if (wantarray) { }
1742 0 0 if ($seen) { }
1746 0 0 if ref $j and $j eq $_[0]
1749 0 0 unless $seen
1754 0 0 $i == $#$pc ? :
0 0 if ref $pc->[$i] and $pc->[$i] eq $_[0]
1766 1 12 if (@_ == 1) { }
1780 0 12 if (@stack and not length $stack[0]) { }
1785 0 12 unless 0 == shift @stack
1792 0 20 unless $here->{'_content'} and @{$here->{'_content'};} > $stack[0]
1796 0 20 if @stack and not ref $here
1849 0 0 if (wantarray) { }
1887 0 3 unless ref $pile[0]
1889 0 3 unless @_
1895 3 13 if ($t eq $this_tag)
1896 0 3 if (wantarray) { }
1905 1 12 unless $this->{'_content'}
1907 0 0 if wantarray
1916 0 3 unless defined $attribute
1926 3 14 if (exists $_[0]{$attribute} and $_[0]{$attribute} eq $value)
1930 3 0 unless $wantarray
1940 0 3 if ($wantarray) { }
1952 0 13 unless ref $_[0]
1956 0 19 unless defined $_[$i]
1958 4 15 if (ref $_[$i]) { }
1959 0 4 unless ref $_[$i] eq 'CODE'
1964 0 15 if $i == $#_
1965 3 12 ref $_[$i + 1] ? :
15 0 defined $_[$i + 1] ? :
1978 0 13 unless @criteria
1987 9 57 if (ref $c eq 'CODE') { }
1988 5 4 unless &$c($this)
1993 57 0 defined($val = $$this{$c->[0]}) ? :
40 17 if defined($val = $$this{$c->[0]}) ? !defined($c->[1]) || ($c->[2] eq 'Regexp' ? !($val =~ /$c->[1]/) : ref $val ne $c->[2] || lc $val ne lc $c->[1]) : defined $c->[1]
2016 9 4 unless wantarray
2020 10 39 unless $this->{'_content'}
2022 3 1 if wantarray
2028 0 1 unless ref $_[0]
2032 0 1 unless defined $_[$i]
2034 0 1 if (ref $_[$i]) { }
2035 0 0 unless ref $_[$i] eq 'CODE'
2040 0 1 if $i == $#_
2041 0 1 ref $_[$i + 1] ? :
1 0 defined $_[$i + 1] ? :
2052 0 1 unless @criteria
2061 0 2 if (ref $c eq 'CODE') { }
2062 0 0 unless &$c($this)
2067 2 0 defined($val = $$this{$c->[0]}) ? :
1 1 if defined($val = $$this{$c->[0]}) ? !defined($c->[1]) || ($c->[2] eq 'Regexp' ? !($val =~ /$c->[1]/) : ref $val ne $c->[2] || lc $val ne $c->[1]) : defined $c->[1]
2088 1 0 unless wantarray
2092 0 1 unless defined($this = $this->{'_parent'}) and ref $this
2095 0 0 if wantarray
2103 0 0 if (@_ > 2) { }
2105 0 0 if grep((!defined($_)), @_)
2108 0 0 if (wantarray) { }
2112 0 0 exists $x->{$_} ? :
2120 0 0 if exists $x->{$attribute}
2130 0 0 unless defined $_[1]
2134 0 0 if (wantarray) { }
2136 0 0 exists $_->{$attribute} ? :
2141 0 0 if exists $x->{$attribute}
2151 0 0 unless ref $pile[0]
2156 0 0 unless defined($this_tag = +($this = shift @pile)->{'_tag'})
2160 0 0 unless $this->{'_content'}
2184 0 0 if $wantType and not $wantType{$tag}
2186 0 0 if (defined($link_attrs = $HTML::Element::linkElements{$tag}))
2195 0 0 ref $link_attrs ? :
2196 0 0 if (defined($val = $self->attr($_)))
2217 0 0 if $_[0]{'_tag'} eq 'pre'
2218 0 0 unless $_[0]{'_content'}
2219 0 0 if (ref $it) { }
0 0 elsif ($pre) { }
2243 0 0 if $_[0]{'_tag'} eq 'pre'
2254 0 25 unless @_ == 2
2256 0 25 unless ref $h
2258 0 25 unless defined $i and ref $i
2263 2 23 if $h eq $i
2273 1 22 unless $h->{'_tag'} eq $i->{'_tag'}
2287 110 0 if length $_
2289 109 0 if length $_
2291 1 21 unless @keys_h == @keys_i
2297 0 8 unless $keys_h[$x] eq $keys_i[$x] and $$h{$keys_h[$x]} eq $$i{$keys_h[$x]}
2307 0 21 unless @$hcl == @$icl
2311 18 3 if (@$hcl)
2315 18 12 if (ref $hcl->[$x]) { }
2316 0 18 unless ref $icl->[$x]
2320 2 16 unless $hcl->[$x]->same_as($icl->[$x])
2323 0 12 if ref $icl->[$x]
2327 0 12 unless $hcl->[$x] eq $icl->[$x]
2352 0 161 unless @$lol
2354 0 161 if grep(($_ eq $lol), @ancestor_lols)
2362 132 292 if (ref $lol->[$i] eq 'ARRAY') { }
279 13 elsif (not ref $lol->[$i]) { }
12 1 elsif (ref $lol->[$i] eq 'HASH') { }
1 0 elsif (UNIVERSAL::isa($lol->[$i], 'HTML::Element')) { }
2367 161 118 if ($i == 0) { }
2369 0 161 if $tag_name =~ m[[<>/\x00-\x20]]
2380 12 0 if defined $v and $k ne '_name' and $k ne '_content' and $k ne '_parent'
2390 0 1 if ($lol->[$i]{'_parent'}) { }
2413 160 1 if ($class eq 'HTML::Element') { }
2414 12 148 if @attributes
2417 156 4 if (@children)
2420 132 118 if ref $c
2429 1 0 if ref $_
1 0 if @children
2439 4 25 if (wantarray) { }
2440 4 0 ref $_ eq 'ARRAY' ? :
2450 0 25 unless @_ == 1
2452 0 25 unless ref $_[0] eq 'ARRAY'
2470 0 0 if (ref $c) { }
2489 0 0 if ($_[0]{'_tag'} eq '~text')
2491 0 0 if ($_[0]{'_parent'}) { }
2498 0 0 if (ref $_[0] eq 'HTML::Element') { }
2507 0 0 unless defined $old_node
2513 0 0 if (ref $c)
2514 0 0 if ($c->{'_tag'} eq '~text') { }
2516 0 0 if (ref $old_node eq 'HTML::Element') { }
2547 0 0 unless defined $_[0]
2548 0 0 if $_[0] < 1 and $_[0] > -1
2549 0 0 if $_[0] <= -1
2557 0 0 unless defined $_[0]
2558 0 0 if $_[0] < 1 and $_[0] > -1
2559 0 0 if $_[0] <= -1
2585 0 0 if 0 == ($i = int($_[0] || 0))
2587 0 0 if $i <= -4000 or $i >= 4000
2590 0 0 if ($i < 0) { }
2599 0 0 if ($i >= 10)
2602 0 0 if ($x >= 10)
2605 0 0 if ($c >= 10)
2631 0 0 if (($tag = +($this = shift @stack)->{'_tag'}) eq 'ol') { }
0 0 elsif ($tag eq 'ul' or $tag eq 'dir' or $tag eq 'menu') { }
2635 0 0 ($this->{'start'} || '') =~ /^\s*(\d{1,7})\s*$/s ? :
2642 0 0 unless $this->{'_content'}
2643 0 0 unless ref $c
2645 0 0 if ($c->{'_tag'} eq 'li')
2648 0 0 if ($c->{'value'} || '') =~ /^\s*(\d{1,7})\s*$/s
2658 0 0 unless $this->{'_content'}
2659 0 0 unless ref $c
2661 0 0 if $c->{'_tag'} eq 'li'
2666 0 0 unless $this->{'_content'}
2667 0 0 if ref $c
2685 0 0 unless ref $c eq 'ARRAY'
2687 0 0 unless @$c
2689 0 0 unless defined $c->[$i]
2691 0 0 if (ref $c->[$i])
2692 0 0 if $c->[$i] eq $this
2696 0 0 if exists $parent_of{$c->[$i]}
2703 0 0 unless defined($p = $c->[$i]{'_parent'})
2704 0 0 unless ref $p
2706 0 0 unless $p eq $this
2723 0 0 if (defined($assert = $this->{'assert'}))
2726 0 0 unless (ref $assert)
2730 0 0 $assert =~ /\bsub\b/ ? :
2736 0 0 if ($@)
2748 0 0 $parent ? :
2752 0 0 if ($@) { }
0 0 elsif (not $rv) { }
2761 0 0 unless $this->{'_content'}
2772 0 3679 unless my $attr = shift()
2775 1 3678 unless $attr =~ /^$START_CHAR$NAME_CHAR+$/
2782 224 0 unless $_[0]{'_element_class'}