Branch Coverage

blib/lib/HTML/Element.pm
Criterion Covered Total %
branch 393 784 50.1


line true false branch
37 32 0 if (@_)
39 0 32 if $using_weaken and not defined &Scalar::Util::weaken
43 32 0 $using_weaken ? :
61 2 0 if (/^-(no_?)?weak$/) { }
168 0 2491 unless defined $tag and length $tag
169 0 2491 if $tag =~ m[[<>/\x00-\x20]]
172 353 2138 if ($tag eq 'html')
179 1 606 unless defined $val
182 0 2491 if $$self{'_parent'}
190 14 13 if (@_) { }
191 13 1 if (defined $_[0]) { }
208 0 1198 if (@_) { }
219 0 118 if (@_) { }
220 0 0 if defined $_[0] and ref $_[0] and $self eq $_[0]
232 1 1 wantarray ? :
2 2 unless (shift())->{'_content'}
238 0 137 unless (shift())->{'_content'}
37 1509 unless (shift())->{'_content'}
239 137 1546 wantarray ? :
255 0 0 unless (shift())->{'_content'}
272 0 8 if (@_)
274 0 0 if (defined $parm and $parm ne $self) { }
281 8 0 if defined $pos
302 6 2 length $_ && substr($_, 0, 1) eq '_' ? :
314 0 0 if (@_ == 1) { }
0 0 elsif (@_ == 2) { }
318 0 0 if (defined $_[1]) { }
333 0 0 unless (defined $ID_COUNTER)
346 0 0 if ($nparms == 1)
348 0 0 if (defined($x = $_[0]{'id'}) and length $x) { }
355 0 0 if ($nparms == 2)
356 0 0 if (defined $_[1]) { }
369 1 4425 unless @_
373 5 4429 if (ref $_ eq 'ARRAY') { }
1827 2602 elsif (ref $_) { }
380 1 1826 if $$_{'_parent'}
385 464 2138 if (@$content and not ref $$content[-1]) { }
401 0 2 unless @_
405 1 1 if (ref $_ eq 'ARRAY') { }
1 0 elsif (ref $_) { }
412 0 1 if $$_{'_parent'}
417 0 0 if (@$content and not ref $$content[0]) { }
435 0 2 if @_ < 2
443 2 0 if (@_ > 2) { }
445 1 1 if (ref $n eq 'ARRAY') { }
1 0 elsif (ref $n) { }
460 4 0 if ref $n
468 3 1 unless my $parent = $$self{'_parent'}
482 4 1 if ref $_
490 0 4 unless my($parent) = $$self{'_parent'}
494 0 4 unless $parent_content and @$parent_content
499 0 8 if (not ref $_) { }
4 4 elsif ($_ eq $self) { }
0 4 elsif ($_ eq $parent) { }
2 2 elsif (ref $_ eq 'ARRAY') { }
506 0 4 if $replacers_contains_self++
523 4 24 ref $_ && $_ eq $self ? :
526 0 4 unless $replacers_contains_self
536 0 2 unless @_
543 0 2 unless @_
550 0 18 unless my($parent) = $$self{'_parent'}
554 0 18 unless $parent_content and @$parent_content
558 18 41 ref $_ && $_ eq $self ? :
564 0 0 if ref $_
572 0 1156 unless delete $_[0]{'_content'}
587 786 1186 if ref $_
600 1156 134 if $$self{'_content'} and @{$$self{'_content'};}
602 0 1290 if $$self{'_parent'} and $$self{'_parent'}{'_content'}
615 0 4 unless ref $it
617 0 4 if @_
623 3 1 if ($$it{'_content'} and @{$$it{'_content'};})
627 3 2 if ref $_
636 0 3 if ref shift @_
640 3 2 ref $_ ? :
652 0 1 unless $c = $$start{'_content'} and ref $c and @$c
661 1 5 if (defined $$c[$i] and ref $$c[$i]) { }
662 1 0 if ($stretches[0])
665 0 1 if ($stretches[0][1] == 1) { }
680 3 2 unless defined $$c[$i]
681 3 2 if ($stretches[0]) { }
695 2 2 if ($s and $$s[1] > 1)
724 0 304 unless ref $_[0]
727 0 304 if $Debug > 2
731 2 2054 if (($ptag = ($this = shift @to_do)->{'_tag'}) eq 'pre' or $ptag eq 'textarea' or $HTML::Tagset::isCDATA_Parent{$ptag})
737 0 3 if $Debug
740 183 1871 unless $sibs = $$this{'_content'} and @$sibs
742 1753 1898 if (ref $$sibs[$i])
749 1314 584 if $$sibs[$i] =~ /[^\n\r\f\t ]/s
751 0 584 if $Debug > 3
757 6 578 if ($i == 0) { }
413 165 elsif ($i == $#$sibs) { }
758 4 2 if (@$sibs == 1) { }
759 1 3 unless $HTML::Element::canTighten{$ptag}
764 2 0 unless $HTML::Element::canTighten{$ptag} or ref $$sibs[1] and $HTML::Element::canTighten{$$sibs[1]{'_tag'}}
774 2 0 unless $HTML::Element::canTighten{$ptag} or ref $$sibs[$i - 1] and $HTML::Element::canTighten{$$sibs[$i - 1]{'_tag'}}
783 0 165 unless ref $$sibs[$i - 1] or ref $$sibs[$i + 1]
792 165 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'}}
803 0 414 if $Debug > 3
818 0 1811 unless $tag
821 1155 656 if (ref $tag) { }
827 656 0 if exists $$self{'_element_count'}
832 656 1155 if $implicit
835 645 1166 unless defined $pos
839 1776 35 unless $self->_empty_element_map->{$tag} or $$e{'_empty_element'}
853 21 3203 if (wantarray) { }
863 0 0 if (wantarray) { }
881 0 46 unless defined $fh
882 6 40 unless defined $depth
883 9 37 $$self{'_implicit'} ? :
886 40 17 if (ref $_) { }
891 0 17 if (length $_ > 65 or /[\x00-\x1F]/) { }
894 0 0 length $_ <= 65 ? :
914 1 5 @_ ? :
916 0 6 unless defined $encoding
918 0 6 unless open my $filehandle, '>:raw', $filename
929 6 0 @_ ? :
931 0 6 unless defined $encoding
935 6 0 length $encoding ? :
937 0 6 unless binmode $filehandle, $encoding
940 4 2 if $bom
963 20 257 if (defined $indent and length $indent) { }
967 576 203 if (ref $node) { }
970 0 576 unless $node->can('starttag')
977 289 287 if ($start) { }
257 30 elsif (not $$empty_element_map{$tag} || $$omissible_map{$tag}) { }
978 207 82 if ($this_tag_tightenable = $HTML::Element::canTighten{$tag} and not $nonindentable_ancestors and $last_tag_tightenable) { }
997 1 287 if $tag eq 'pre' or $tag eq 'textarea' or $HTML::Tagset::isCDATA_Parent{$tag}
1009 2 255 if ($tag eq 'pre' or $tag eq 'textarea' or $HTML::Tagset::isCDATA_Parent{$tag}) { }
1019 112 143 if ($this_tag_tightenable = $HTML::Element::canTighten{$tag} and not $nonindentable_ancestors and $last_tag_tightenable) { }
1045 203 0 unless defined $entities and not length $entities or $HTML::Tagset::isCDATA_Parent{$_[3]{'_tag'}} or $encoded_content
1060 0 203 if ($nonindentable_ancestors) { }
1064 0 203 if ($last_tag_tightenable) { }
1096 2421 1167 if (ref $node) { }
1099 0 2421 unless $node->isa($self->element_class)
1105 1213 1208 if ($start) { }
1186 22 elsif (not $$empty_element_map{$tag} || $$omissible_map{$tag}) { }
1121 1163 1 unless defined $entities and not length $entities or $HTML::Tagset::isCDATA_Parent{$_[3]{'_tag'}} or $encoded_content
1143 1 276 if ($$self{'_store_declarations'} and defined $$self{'_decl'})
1156 0 9 unless $ISA[0] eq ref $elt
1183 0 129 if (not defined $pile[0]) { }
62 67 elsif (not ref $pile[0]) { }
1190 7 60 unless $$this{'_content'}
67 0 unless ($tag = ($this = shift @pile)->{'_tag'}) eq 'style' or $tag eq 'script' or $skip_dels and $tag eq 'del'
1203 3 10 defined $options{'extra_chars'} ? :
1230 1236 236 if (ref $node) { }
1232 626 610 if ($start) { }
1235 1 4064 unless $attr eq '/' or $self->_valid_name($attr)
1240 13 1 unless $$node{'_content'}
13 612 if ($$empty_element_map{$tag} and not @{$nillio unless $$node{'_content'};}) { }
1250 0 1 unless $$node{'_content'}
610 0 unless ($$empty_element_map{$tag} and not @{$nillio unless $$node{'_content'};})
1276 26 268 if ($encoded_content) { }
1315 0 1 unless defined $list[-1]
1319 1 1 if $_ eq '_content' or $_ eq '_tag' or $_ eq '_parent' or $_ eq '/'
1325 1 0 if defined($val = $$self{$_})
1337 0 1 unless $$self{'_content'}
1 0 if (@{$nillio unless $$self{'_content'};}) { }
1341 0 1 if (ref $c) { }
1379 6 20 ref $_ ? :
1380 4 16 unless $$self{'_content'}
1385 16 16 if $_ ne '_tag' and $_ ne '_name' and $_ ne '_content'
1395 6 14 @real_keys ? :
1406 2 5 if ref $$lol[0] eq 'HASH'
1413 0 0 unless (defined $formatter)
1427 0 1543 if $name eq '~literal'
1428 0 1543 if $name eq '~declaration'
1429 0 1543 if $name eq '~pi'
1431 0 1543 if ($name eq '~comment')
1432 0 0 if (ref($$self{'text'} || '') eq 'ARRAY') { }
1444 0 1543 $html_uc ? :
1447 8526 507 if not length $_ or /^_/s or $_ eq '/'
1449 0 507 unless defined $val
1450 1 0 ref $HTML::Element::boolean_attr{$name} ? :
0 507 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 $_) { }
1458 0 0 $html_uc ? :
1462 1 506 if (ref $val eq 'HTML::Element' and $$val{'_tag'} eq '~literal') { }
1468 506 0 unless defined $entities and not length $entities or $encoded_content
1477 0 507 $html_uc ? :
1480 12 1531 if (scalar $self->content_list == 0 and $self->_empty_element_map->{$self->tag}) { }
1498 0 622 if $name eq '~literal'
1499 0 622 if $name eq '~declaration'
1500 0 622 if $name eq '~pi'
1502 1 621 if ($name eq '~comment')
1503 0 1 if (ref($$self{'text'} || '') eq 'ARRAY') { }
1518 4023 32 if not length $_ or /^_/s or $_ eq '/'
1522 0 32 unless defined($val = $$self{$_})
1526 12 609 @_ == 3 ? :
1531 0 1439 $html_uc ? :
1567 0 409 unless ref $start
1570 0 409 unless defined $callback and ref $callback
1575 406 3 if (UNIVERSAL::isa($callback, 'CODE')) { }
3 0 elsif (UNIVERSAL::isa($callback, 'ARRAY')) { }
1580 0 3 if $c_pre and not UNIVERSAL::isa($c_pre, 'CODE')
1583 0 3 if $c_post and not UNIVERSAL::isa($c_post, 'CODE')
1586 0 3 unless $c_pre or $c_post
1591 0 0 unless ref $callback
1612 2518 3759 if (not defined $I[0] or ++$I[0] >= @{$C[0];})
1616 2105 413 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'};}) { }
1643 0 2105 if (defined $rv and ref $rv eq $travsignal_package)
1645 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') { }
1679 3759 0 if ($c_pre)
1680 2145 1614 if (defined $this and ref $this) { }
1690 8 1606 if $ignore_text
1703 0 3750 if (not $rv) { }
3 3747 elsif (ref $rv eq $travsignal_package) { }
1708 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') { }
1715 0 0 if (ref $this and not $$this{'_empty_element'} || $$empty_element_map{$$this{'_tag'} or ''})
1755 2121 1626 if (ref $this and not !(($content_r = $$this{'_content'}) && @$content_r) && ($$this{'_empty_element'} || $$empty_element_map{$$this{'_tag'} or ''}))
1779 0 3569 unless @_
1786 0 14985 if (ref $_) { }
1787 0 0 if $_ eq $current
1790 383 14602 if $_ eq $$current{'_tag'}
1811 82 58 if ref $$pc[$i] and $$pc[$i] eq $self
1820 0 0 unless ref $_[0]
1825 0 0 unless @$pc
1826 0 0 if @$pc == 1
1828 0 0 if (wantarray) { }
1831 0 0 if ref $j and $j eq $_[0]
1837 0 0 $i ? :
0 0 if ref $$pc[$i] and $$pc[$i] eq $_[0]
1848 0 0 unless ref $_[0]
1853 0 0 unless @$pc
1854 0 0 if @$pc == 1
1856 0 0 if (wantarray) { }
1859 0 0 if ($seen) { }
1863 0 0 if ref $j and $j eq $_[0]
1866 0 0 unless $seen
1871 0 0 $i == $#$pc ? :
0 0 if ref $$pc[$i] and $$pc[$i] eq $_[0]
1883 47 12 if (@_ == 1) { }
1897 0 12 if (@stack and not length $stack[0]) { }
1902 0 12 unless 0 == shift @stack
1909 0 20 unless $$here{'_content'} and @{$$here{'_content'};} > $stack[0]
1913 0 20 if @stack and not ref $here
1966 0 0 if (wantarray) { }
2004 0 3 unless ref $pile[0]
2006 0 3 unless @_
2012 3 13 if ($t eq $this_tag)
2013 0 3 if (wantarray) { }
2022 1 12 unless $$this{'_content'}
2024 0 0 if wantarray
2033 0 3 unless defined $attribute
2043 3 14 if (exists $_[0]{$attribute} and $_[0]{$attribute} eq $value)
2047 3 0 unless $wantarray
2057 0 3 if ($wantarray) { }
2069 0 72 unless ref $_[0]
2073 0 78 unless defined $_[$i]
2075 4 74 if (ref $_[$i]) { }
2076 0 4 unless ref $_[$i] eq 'CODE'
2081 0 74 if $i == $#_
2082 5 69 ref $_[$i + 1] ? :
74 0 defined $_[$i + 1] ? :
2095 0 72 unless @criteria
2104 9 631 if (ref $c eq 'CODE') { }
2105 5 4 unless &$c($this)
2110 296 335 defined($val = $$this{$$c[0]}) ? :
546 85 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]
2133 59 22 unless wantarray
2137 142 431 unless $$this{'_content'}
2139 11 2 if wantarray
2145 0 1 unless ref $_[0]
2149 0 1 unless defined $_[$i]
2151 0 1 if (ref $_[$i]) { }
2152 0 0 unless ref $_[$i] eq 'CODE'
2157 0 1 if $i == $#_
2158 0 1 ref $_[$i + 1] ? :
1 0 defined $_[$i + 1] ? :
2169 0 1 unless @criteria
2178 0 2 if (ref $c eq 'CODE') { }
2179 0 0 unless &$c($this)
2184 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]
2205 1 0 unless wantarray
2209 0 1 unless defined($this = $$this{'_parent'}) and ref $this
2212 0 0 if wantarray
2220 0 0 if (@_ > 2) { }
2222 0 0 if grep((!defined($_)), @_)
2225 0 0 if (wantarray) { }
2228 0 0 exists $$x{$_} ? :
2236 0 0 if exists $$x{$attribute}
2247 0 0 unless defined $_[1]
2251 0 0 if (wantarray) { }
2253 0 0 exists $$_{$attribute} ? :
2258 0 0 if exists $$x{$attribute}
2268 0 0 unless ref $pile[0]
2272 0 0 unless defined($this_tag = ($this = shift @pile)->{'_tag'})
2276 0 0 unless $$this{'_content'}
2300 0 0 if $wantType and not $wantType{$tag}
2303 0 0 if (defined($link_attrs = $HTML::Element::linkElements{$tag}))
2312 0 0 ref $link_attrs ? :
2313 0 0 if (defined($val = $self->attr($_)))
2334 0 0 if $_[0]{'_tag'} eq 'pre'
2335 0 0 unless $_[0]{'_content'}
2336 0 0 if (ref $it) { }
0 0 elsif ($pre) { }
2360 0 0 if $_[0]{'_tag'} eq 'pre'
2371 0 25 unless @_ == 2
2373 0 25 unless ref $h
2375 0 25 unless defined $i and ref $i
2380 2 23 if $h eq $i
2390 1 22 unless $$h{'_tag'} eq $$i{'_tag'}
2404 116 0 if length $_
2406 115 0 if length $_
2408 1 21 unless @keys_h == @keys_i
2412 0 8 unless $keys_h[$x] eq $keys_i[$x] and $$h{$keys_h[$x]} eq $$i{$keys_h[$x]}
2424 0 21 unless @$hcl == @$icl
2428 18 3 if (@$hcl)
2432 18 12 if (ref $$hcl[$x]) { }
2433 0 18 unless ref $$icl[$x]
2437 2 16 unless $$hcl[$x]->same_as($$icl[$x])
2440 0 12 if ref $$icl[$x]
2444 0 12 unless $$hcl[$x] eq $$icl[$x]
2469 0 192 unless @$lol
2471 0 192 if grep(($_ eq $lol), @ancestor_lols)
2479 144 357 if (ref $$lol[$i] eq 'ARRAY') { }
338 19 elsif (not ref $$lol[$i]) { }
18 1 elsif (ref $$lol[$i] eq 'HASH') { }
1 0 elsif (UNIVERSAL::isa($$lol[$i], 'HTML::Element')) { }
2484 192 146 if ($i == 0) { }
2486 0 192 if $tag_name =~ m[[<>/\x00-\x20]]
2497 18 0 if defined $v and $k ne '_name' and $k ne '_content' and $k ne '_parent'
2507 0 1 if ($$lol[$i]{'_parent'}) { }
2530 191 1 if ($class eq 'HTML::Element') { }
2531 16 175 if @attributes
2534 182 9 if (@children)
2537 144 146 if ref $c
2546 1 0 if ref $_
1 0 if @children
2556 6 42 if (wantarray) { }
2557 6 0 ref $_ eq 'ARRAY' ? :
2567 0 42 unless @_ == 1
2569 0 42 unless ref $_[0] eq 'ARRAY'
2587 0 0 if (ref $c) { }
2606 0 0 if ($_[0]{'_tag'} eq '~text')
2608 0 0 if ($_[0]{'_parent'}) { }
2615 0 0 if (ref $_[0] eq 'HTML::Element') { }
2624 0 0 unless defined $old_node
2630 0 0 if (ref $c)
2631 0 0 if ($$c{'_tag'} eq '~text') { }
2633 0 0 if (ref $old_node eq 'HTML::Element') { }
2664 0 0 unless defined $_[0]
2665 0 0 if $_[0] < 1 and $_[0] > -1
2666 0 0 if $_[0] <= -1
2674 0 0 unless defined $_[0]
2675 0 0 if $_[0] < 1 and $_[0] > -1
2676 0 0 if $_[0] <= -1
2702 0 0 if 0 == ($i = int($_[0] || 0))
2704 0 0 if $i <= -4000 or $i >= 4000
2707 0 0 if ($i < 0) { }
2716 0 0 if ($i >= 10)
2719 0 0 if ($x >= 10)
2722 0 0 if ($c >= 10)
2748 0 0 if (($tag = ($this = shift @stack)->{'_tag'}) eq 'ol') { }
0 0 elsif ($tag eq 'ul' or $tag eq 'dir' or $tag eq 'menu') { }
2751 0 0 ($$this{'start'} || '') =~ /^\s*(\d{1,7})\s*$/s ? :
2759 0 0 unless $$this{'_content'}
2760 0 0 unless ref $c
2762 0 0 if ($$c{'_tag'} eq 'li')
2763 0 0 if ($$c{'value'} || '') =~ /^\s*(\d{1,7})\s*$/s
2775 0 0 unless $$this{'_content'}
2776 0 0 unless ref $c
2778 0 0 if $$c{'_tag'} eq 'li'
2783 0 0 unless $$this{'_content'}
2784 0 0 if ref $c
2802 0 0 unless ref $c eq 'ARRAY'
2804 0 0 unless @$c
2806 0 0 unless defined $$c[$i]
2808 0 0 if (ref $$c[$i])
2809 0 0 if $$c[$i] eq $this
2811 0 0 if exists $parent_of{$$c[$i]}
2818 0 0 unless defined($p = $$c[$i]{'_parent'})
2821 0 0 unless ref $p
2823 0 0 unless $p eq $this
2840 0 0 if (defined($assert = $$this{'assert'}))
2843 0 0 unless (ref $assert)
2847 0 0 $assert =~ /\bsub\b/ ? :
2853 0 0 if ($@)
2862 0 0 $parent ? :
2869 0 0 if ($@) { }
0 0 elsif (not $rv) { }
2878 0 0 unless $$this{'_content'}
2889 0 4060 unless my $attr = shift()
2892 1 4059 unless $attr =~ /^$START_CHAR$NAME_CHAR*$/
2899 260 0 unless $_[0]{'_element_class'}