Branch Coverage

blib/lib/HTML/Element.pm
Criterion Covered Total %
branch 396 784 50.5


line true false branch
37 33 1 if (@_)
39 0 33 if $using_weaken and not defined &Scalar::Util::weaken
43 32 1 $using_weaken ? :
61 2 0 if (/^-(no_?)?weak$/) { }
168 0 2867 unless defined $tag and length $tag
169 0 2867 if $tag =~ m[[<>/\x00-\x20]]
172 433 2434 if ($tag eq 'html')
179 1 606 unless defined $val
182 0 2867 if $self->{'_parent'}
190 46 13 if (@_) { }
191 37 9 if (defined $_[0]) { }
208 0 1222 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 177 unless (shift())->{'_content'}
239 37 1525 unless (shift())->{'_content'}
177 1562 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
304 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 4665 unless @_
373 5 4701 if (ref $_ eq 'ARRAY') { }
2027 2674 elsif (ref $_) { }
380 1 2026 if $_->{'_parent'}
385 488 2186 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 36 9 if ref $_
491 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 @_
551 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 $_
573 0 1268 unless delete $_[0]{'_content'}
588 890 1254 if ref $_
601 1268 190 if $self->{'_content'} and @{$self->{'_content'};}
603 0 1430 if $self->{'_parent'} and $self->{'_parent'}{'_content'}
616 0 4 unless ref $it
618 0 4 if @_
624 3 1 if ($it->{'_content'} and @{$it->{'_content'};})
628 3 2 if ref $_
637 0 3 if ref shift @_
642 3 2 ref $_ ? :
653 0 9 unless $c = $start->{'_content'} and ref $c and @$c
662 9 45 if (defined $c->[$i] and ref $c->[$i]) { }
663 9 0 if ($stretches[0])
666 0 9 if ($stretches[0][1] == 1) { }
681 27 18 unless defined $c->[$i]
682 27 18 if ($stretches[0]) { }
696 18 18 if ($s and $s->[1] > 1)
725 0 368 unless ref $_[0]
728 0 368 if $Debug > 2
732 2 2286 if (($ptag = ($this = shift @to_do)->{'_tag'}) eq 'pre' or $ptag eq 'textarea' or $HTML::Tagset::isCDATA_Parent{$ptag})
738 0 3 if $Debug
741 271 2015 unless $sibs = $this->{'_content'} and @$sibs
743 1921 1938 if (ref $sibs->[$i])
750 1354 584 if $sibs->[$i] =~ /[^\n\r\f\t ]/s
753 0 584 if $Debug > 3
758 6 578 if ($i == 0) { }
413 165 elsif ($i == $#$sibs) { }
759 4 2 if (@$sibs == 1) { }
760 1 3 unless $HTML::Element::canTighten{$ptag}
768 2 0 unless $HTML::Element::canTighten{$ptag} or ref $sibs->[1] and $HTML::Element::canTighten{$sibs->[1]{'_tag'}}
778 2 0 unless $HTML::Element::canTighten{$ptag} or ref $$sibs[$i - 1] and $HTML::Element::canTighten{$$sibs[$i - 1]{'_tag'}}
784 0 165 unless ref $$sibs[$i - 1] or ref $$sibs[$i + 1]
798 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'}}
804 0 414 if $Debug > 3
819 0 1979 unless $tag
822 1179 800 if (ref $tag) { }
828 800 0 if exists $self->{'_element_count'}
833 800 1179 if $implicit
836 773 1206 unless defined $pos
841 1936 0 unless $self->_empty_element_map->{$tag} or $e->{'_empty_element'}
854 101 3635 if (wantarray) { }
864 0 0 if (wantarray) { }
882 0 46 unless defined $fh
883 6 40 unless defined $depth
885 9 37 $self->{'_implicit'} ? :
887 40 17 if (ref $_) { }
892 0 17 if (length $_ > 65 or /[\x00-\x1F]/) { }
895 0 0 length $_ <= 65 ? :
915 1 5 @_ ? :
917 0 6 unless defined $encoding
919 0 6 unless open my $filehandle, '>:raw', $filename
930 6 0 @_ ? :
932 0 6 unless defined $encoding
936 6 0 length $encoding ? :
938 0 6 unless binmode $filehandle, $encoding
941 4 2 if $bom
964 20 257 if (defined $indent and length $indent) { }
968 576 203 if (ref $node) { }
971 0 576 unless $node->can('starttag')
978 289 287 if ($start) { }
257 30 elsif (not $empty_element_map->{$tag} || $omissible_map->{$tag}) { }
979 207 82 if ($this_tag_tightenable = $HTML::Element::canTighten{$tag} and not $nonindentable_ancestors and $last_tag_tightenable) { }
1000 1 287 if $tag eq 'pre' or $tag eq 'textarea' or $HTML::Tagset::isCDATA_Parent{$tag}
1010 2 255 if ($tag eq 'pre' or $tag eq 'textarea' or $HTML::Tagset::isCDATA_Parent{$tag}) { }
1020 112 143 if ($this_tag_tightenable = $HTML::Element::canTighten{$tag} and not $nonindentable_ancestors and $last_tag_tightenable) { }
1053 203 0 unless defined $entities and not length $entities or $HTML::Tagset::isCDATA_Parent{$_[3]{'_tag'}} or $encoded_content
1061 0 203 if ($nonindentable_ancestors) { }
1065 0 203 if ($last_tag_tightenable) { }
1097 2421 1167 if (ref $node) { }
1100 0 2421 unless $node->isa($self->element_class)
1106 1213 1208 if ($start) { }
1186 22 elsif (not $empty_element_map->{$tag} || $omissible_map->{$tag}) { }
1129 1163 1 unless defined $entities and not length $entities or $HTML::Tagset::isCDATA_Parent{$_[3]{'_tag'}} or $encoded_content
1144 1 276 if ($self->{'_store_declarations'} and defined $self->{'_decl'})
1157 0 9 unless $ISA[0] eq ref $elt
1184 0 129 if (not defined $pile[0]) { }
62 67 elsif (not ref $pile[0]) { }
1191 7 60 unless $this->{'_content'}
1192 67 0 unless ($tag = ($this = shift @pile)->{'_tag'}) eq 'style' or $tag eq 'script' or $skip_dels and $tag eq 'del'
1205 3 10 defined $options{'extra_chars'} ? :
1231 1236 236 if (ref $node) { }
1233 626 610 if ($start) { }
1236 1 4066 unless $attr eq '/' or $self->_valid_name($attr)
1241 13 612 if ($empty_element_map->{$tag} and not @{$nillio unless $node->{'_content'};}) { }
1242 13 1 unless $node->{'_content'}
1251 610 0 unless ($empty_element_map->{$tag} and not @{$nillio unless $node->{'_content'};})
1252 0 1 unless $node->{'_content'}
1277 26 268 if ($encoded_content) { }
1330 0 1 unless defined $list[-1]
1334 1 1 if $_ eq '_content' or $_ eq '_tag' or $_ eq '_parent' or $_ eq '/'
1341 1 0 if defined($val = $self->{$_})
1352 0 1 unless $self->{'_content'}
1 0 if (@{$nillio unless $self->{'_content'};}) { }
1356 0 1 if (ref $c) { }
1395 6 20 ref $_ ? :
1396 4 16 unless $self->{'_content'}
1401 16 16 if $_ ne '_tag' and $_ ne '_name' and $_ ne '_content'
1411 6 14 @real_keys ? :
1421 2 5 if ref $lol->[0] eq 'HASH'
1428 0 0 unless (defined $formatter)
1442 0 1543 if $name eq '~literal'
1443 0 1543 if $name eq '~declaration'
1444 0 1543 if $name eq '~pi'
1446 0 1543 if ($name eq '~comment')
1447 0 0 if (ref($self->{'text'} || '') eq 'ARRAY') { }
1459 0 1543 $html_uc ? :
1462 8526 507 if not length $_ or /^_/s or $_ eq '/'
1464 0 507 unless defined $val
1465 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 $_) { }
1473 0 0 $html_uc ? :
1477 1 506 if (ref $val eq 'HTML::Element' and $val->{'_tag'} eq '~literal') { }
1483 506 0 unless defined $entities and not length $entities or $encoded_content
1492 0 507 $html_uc ? :
1495 12 1531 if (scalar $self->content_list == 0 and $self->_empty_element_map->{$self->tag}) { }
1513 0 622 if $name eq '~literal'
1514 0 622 if $name eq '~declaration'
1515 0 622 if $name eq '~pi'
1517 1 621 if ($name eq '~comment')
1518 0 1 if (ref($self->{'text'} || '') eq 'ARRAY') { }
1533 4023 32 if not length $_ or /^_/s or $_ eq '/'
1537 0 32 unless defined($val = $self->{$_})
1541 12 609 @_ == 3 ? :
1546 0 1439 $html_uc ? :
1582 0 425 unless ref $start
1585 0 425 unless defined $callback and ref $callback
1590 406 19 if (UNIVERSAL::isa($callback, 'CODE')) { }
19 0 elsif (UNIVERSAL::isa($callback, 'ARRAY')) { }
1595 0 19 if $c_pre and not UNIVERSAL::isa($c_pre, 'CODE')
1598 0 19 if $c_post and not UNIVERSAL::isa($c_post, 'CODE')
1601 0 19 unless $c_pre or $c_post
1606 0 0 unless ref $callback
1627 2574 3919 if (not defined $I[0] or ++$I[0] >= @{$C[0];})
1631 2105 469 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'};}) { }
1658 0 2105 if (defined $rv and ref $rv eq $travsignal_package)
1660 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') { }
1694 3919 0 if ($c_pre)
1695 2249 1670 if (defined $this and ref $this) { }
1705 64 1606 if $ignore_text
1718 0 3854 if (not $rv) { }
19 3835 elsif (ref $rv eq $travsignal_package) { }
1723 19 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') { }
1730 0 0 if (ref $this and not $this->{'_empty_element'} || $$empty_element_map{$this->{'_tag'} or ''})
1770 2209 1626 if (ref $this and not !(($content_r = $this->{'_content'}) && @$content_r) && ($this->{'_empty_element'} || $$empty_element_map{$this->{'_tag'} or ''}))
1794 0 3681 unless @_
1799 963 2718 if (scalar @_ == 1) { }
1801 383 838 if $current eq $_[0] or $current->{'_tag'} eq $_[0]
1808 0 6683 if $elements{$current} or $elements{$current->{'_tag'}}
1828 82 58 if ref $pc->[$i] and $pc->[$i] eq $self
1837 0 0 unless ref $_[0]
1842 0 0 unless @$pc
1843 0 0 if @$pc == 1
1845 0 0 if (wantarray) { }
1848 0 0 if ref $j and $j eq $_[0]
1854 0 0 $i ? :
0 0 if ref $pc->[$i] and $pc->[$i] eq $_[0]
1865 0 0 unless ref $_[0]
1870 0 0 unless @$pc
1871 0 0 if @$pc == 1
1873 0 0 if (wantarray) { }
1876 0 0 if ($seen) { }
1880 0 0 if ref $j and $j eq $_[0]
1883 0 0 unless $seen
1888 0 0 $i == $#$pc ? :
0 0 if ref $pc->[$i] and $pc->[$i] eq $_[0]
1900 47 20 if (@_ == 1) { }
1914 0 20 if (@stack and not length $stack[0]) { }
1919 0 20 unless 0 == shift @stack
1926 0 36 unless $here->{'_content'} and @{$here->{'_content'};} > $stack[0]
1930 0 36 if @stack and not ref $here
1983 0 0 if (wantarray) { }
2021 0 19 unless ref $pile[0]
2023 0 19 unless @_
2029 19 93 if ($t eq $this_tag)
2030 0 19 if (wantarray) { }
2039 1 92 unless $this->{'_content'}
2041 0 0 if wantarray
2050 0 19 unless defined $attribute
2060 19 102 if (exists $_[0]{$attribute} and $_[0]{$attribute} eq $value)
2064 19 0 unless $wantarray
2074 0 19 if ($wantarray) { }
2086 0 72 unless ref $_[0]
2090 0 78 unless defined $_[$i]
2092 4 74 if (ref $_[$i]) { }
2093 0 4 unless ref $_[$i] eq 'CODE'
2098 0 74 if $i == $#_
2099 5 69 ref $_[$i + 1] ? :
74 0 defined $_[$i + 1] ? :
2112 0 72 unless @criteria
2121 9 631 if (ref $c eq 'CODE') { }
2122 5 4 unless &$c($this)
2127 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]
2150 59 22 unless wantarray
2154 142 431 unless $this->{'_content'}
2156 11 2 if wantarray
2162 0 9 unless ref $_[0]
2166 0 9 unless defined $_[$i]
2168 0 9 if (ref $_[$i]) { }
2169 0 0 unless ref $_[$i] eq 'CODE'
2174 0 9 if $i == $#_
2175 0 9 ref $_[$i + 1] ? :
9 0 defined $_[$i + 1] ? :
2186 0 9 unless @criteria
2195 0 18 if (ref $c eq 'CODE') { }
2196 0 0 unless &$c($this)
2201 18 0 defined($val = $$this{$c->[0]}) ? :
9 9 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]
2222 9 0 unless wantarray
2226 0 9 unless defined($this = $this->{'_parent'}) and ref $this
2229 0 0 if wantarray
2237 0 0 if (@_ > 2) { }
2239 0 0 if grep((!defined($_)), @_)
2242 0 0 if (wantarray) { }
2246 0 0 exists $x->{$_} ? :
2254 0 0 if exists $x->{$attribute}
2264 0 0 unless defined $_[1]
2268 0 0 if (wantarray) { }
2270 0 0 exists $_->{$attribute} ? :
2275 0 0 if exists $x->{$attribute}
2285 0 0 unless ref $pile[0]
2290 0 0 unless defined($this_tag = ($this = shift @pile)->{'_tag'})
2294 0 0 unless $this->{'_content'}
2318 0 0 if $wantType and not $wantType{$tag}
2320 0 0 if (defined($link_attrs = $HTML::Element::linkElements{$tag}))
2329 0 0 ref $link_attrs ? :
2330 0 0 if (defined($val = $self->attr($_)))
2351 0 0 if $_[0]{'_tag'} eq 'pre'
2352 0 0 unless $_[0]{'_content'}
2353 0 0 if (ref $it) { }
0 0 elsif ($pre) { }
2377 0 0 if $_[0]{'_tag'} eq 'pre'
2388 0 25 unless @_ == 2
2390 0 25 unless ref $h
2392 0 25 unless defined $i and ref $i
2397 2 23 if $h eq $i
2407 1 22 unless $h->{'_tag'} eq $i->{'_tag'}
2421 116 0 if length $_
2423 115 0 if length $_
2425 1 21 unless @keys_h == @keys_i
2431 0 8 unless $keys_h[$x] eq $keys_i[$x] and $$h{$keys_h[$x]} eq $$i{$keys_h[$x]}
2441 0 21 unless @$hcl == @$icl
2445 18 3 if (@$hcl)
2449 18 12 if (ref $hcl->[$x]) { }
2450 0 18 unless ref $icl->[$x]
2454 2 16 unless $hcl->[$x]->same_as($icl->[$x])
2457 0 12 if ref $icl->[$x]
2461 0 12 unless $hcl->[$x] eq $icl->[$x]
2486 0 336 unless @$lol
2488 0 336 if grep(($_ eq $lol), @ancestor_lols)
2496 264 661 if (ref $lol->[$i] eq 'ARRAY') { }
578 83 elsif (not ref $lol->[$i]) { }
82 1 elsif (ref $lol->[$i] eq 'HASH') { }
1 0 elsif (UNIVERSAL::isa($lol->[$i], 'HTML::Element')) { }
2501 336 242 if ($i == 0) { }
2503 0 336 if $tag_name =~ m[[<>/\x00-\x20]]
2514 82 0 if defined $v and $k ne '_name' and $k ne '_content' and $k ne '_parent'
2524 0 1 if ($lol->[$i]{'_parent'}) { }
2547 335 1 if ($class eq 'HTML::Element') { }
2548 80 255 if @attributes
2551 302 33 if (@children)
2554 264 242 if ref $c
2563 1 0 if ref $_
1 0 if @children
2573 6 66 if (wantarray) { }
2574 6 0 ref $_ eq 'ARRAY' ? :
2584 0 66 unless @_ == 1
2586 0 66 unless ref $_[0] eq 'ARRAY'
2604 0 0 if (ref $c) { }
2623 0 0 if ($_[0]{'_tag'} eq '~text')
2625 0 0 if ($_[0]{'_parent'}) { }
2632 0 0 if (ref $_[0] eq 'HTML::Element') { }
2641 0 0 unless defined $old_node
2647 0 0 if (ref $c)
2648 0 0 if ($c->{'_tag'} eq '~text') { }
2650 0 0 if (ref $old_node eq 'HTML::Element') { }
2681 0 0 unless defined $_[0]
2682 0 0 if $_[0] < 1 and $_[0] > -1
2683 0 0 if $_[0] <= -1
2691 0 0 unless defined $_[0]
2692 0 0 if $_[0] < 1 and $_[0] > -1
2693 0 0 if $_[0] <= -1
2719 0 0 if 0 == ($i = int($_[0] || 0))
2721 0 0 if $i <= -4000 or $i >= 4000
2724 0 0 if ($i < 0) { }
2733 0 0 if ($i >= 10)
2736 0 0 if ($x >= 10)
2739 0 0 if ($c >= 10)
2765 0 0 if (($tag = ($this = shift @stack)->{'_tag'}) eq 'ol') { }
0 0 elsif ($tag eq 'ul' or $tag eq 'dir' or $tag eq 'menu') { }
2769 0 0 ($this->{'start'} || '') =~ /^\s*(\d{1,7})\s*$/s ? :
2776 0 0 unless $this->{'_content'}
2777 0 0 unless ref $c
2779 0 0 if ($c->{'_tag'} eq 'li')
2782 0 0 if ($c->{'value'} || '') =~ /^\s*(\d{1,7})\s*$/s
2792 0 0 unless $this->{'_content'}
2793 0 0 unless ref $c
2795 0 0 if $c->{'_tag'} eq 'li'
2800 0 0 unless $this->{'_content'}
2801 0 0 if ref $c
2819 0 0 unless ref $c eq 'ARRAY'
2821 0 0 unless @$c
2823 0 0 unless defined $c->[$i]
2825 0 0 if (ref $c->[$i])
2826 0 0 if $c->[$i] eq $this
2830 0 0 if exists $parent_of{$c->[$i]}
2837 0 0 unless defined($p = $c->[$i]{'_parent'})
2838 0 0 unless ref $p
2840 0 0 unless $p eq $this
2857 0 0 if (defined($assert = $this->{'assert'}))
2860 0 0 unless (ref $assert)
2864 0 0 $assert =~ /\bsub\b/ ? :
2870 0 0 if ($@)
2882 0 0 $parent ? :
2886 0 0 if ($@) { }
0 0 elsif (not $rv) { }
2895 0 0 unless $this->{'_content'}
2906 0 4062 unless my $attr = shift()
2909 1 4061 unless $attr =~ /^$START_CHAR$NAME_CHAR*$/
2916 260 0 unless $_[0]{'_element_class'}