Branch Coverage

blib/lib/HTML/DOM/_Element.pm
Criterion Covered Total %
branch 221 742 29.7


line true false branch
108 0 2153 unless defined $tag and length $tag
109 0 2153 if $tag =~ m[[<>/\x00-\x20]]
115 7 1156 unless defined $val
118 162 1991 if ($tag eq 'html')
127 1405 8511 if (@_) { }
128 1342 63 if (defined $_[0]) { }
144 1 8666 if (@_) { }
154 7 5559 if (@_) { }
155 0 0 if defined $_[0] and ref $_[0] and $self eq $_[0]
166 2250 3282 unless +(shift())->{'_content'}
167 37 159 unless +(shift())->{'_content'}
5532 196 wantarray ? :
180 0 0 unless +(shift())->{'_content'}
190 0 18 if (@_)
192 0 0 if (defined $parm and $parm ne $self) { }
199 18 0 if defined $pos
220 0 0 length $_ && substr($_, 0, 1) eq '_' ? :
229 997 0 if (@_ == 1) { }
0 0 elsif (@_ == 2) { }
233 0 0 if (defined $_[1]) { }
246 0 0 unless (defined $HTML::DOM::_Element::ID_COUNTER)
259 0 0 if ($nparms == 1)
261 0 0 if (defined($x = $_[0]{'id'}) and length $x) { }
268 0 0 if ($nparms == 2)
269 0 0 if (defined $_[1]) { }
281 0 1696 unless @_
285 0 1712 if (ref $_ eq 'ARRAY') { }
1164 548 elsif (ref $_) { }
292 44 1120 if $_->{'_parent'}
297 0 548 if (@$content and not ref $content->[-1]) { }
312 0 8 unless @_
316 0 8 if (ref $_ eq 'ARRAY') { }
8 0 elsif (ref $_) { }
323 2 6 if $_->{'_parent'}
328 0 0 if (@$content and not ref $content->[0]) { }
345 0 562 if @_ < 2
347 0 562 unless @_
354 562 0 if (@_ > 2) { }
356 0 564 if (ref $n eq 'ARRAY') { }
564 0 elsif (ref $n) { }
371 1 548 if ref $n
378 592 120 unless my $parent = $self->{'_parent'}
391 55 0 if ref $_
399 0 41 unless my($parent) = $self->{'_parent'}
402 0 41 unless $parent_content and @$parent_content
407 0 65 if (not ref $_) { }
23 42 elsif ($_ eq $self) { }
0 42 elsif ($_ eq $parent) { }
0 42 elsif (ref $_ eq 'ARRAY') { }
414 0 23 if $replacers_contains_self++
431 41 36 ref $_ && $_ eq $self ? :
434 18 23 unless $replacers_contains_self
443 0 13 unless @_
449 0 10 unless @_
456 0 0 unless my($parent) = $self->{'_parent'}
459 0 0 unless $parent_content and @$parent_content
463 0 0 ref $_ && $_ eq $self ? :
469 0 0 if ref $_
477 8 38 unless delete $_[0]{'_content'}
491 61 0 if ref $_
503 19 157 if $self->{'_content'} and @{$self->{'_content'};}
505 6 61 if $self->{'_parent'} and $self->{'_parent'}{'_content'}
517 0 322 unless ref $it
519 0 322 if @_
525 137 185 if ($it->{'_content'} and @{$it->{'_content'};})
529 247 0 if ref $_
537 0 137 if ref shift @_
542 247 0 ref $_ ? :
552 0 0 unless $c = $start->{'_content'} and ref $c and @$c
561 0 0 if (defined $c->[$i] and ref $c->[$i]) { }
562 0 0 if ($stretches[0])
565 0 0 if ($stretches[0][1] == 1) { }
580 0 0 unless defined $c->[$i]
581 0 0 if ($stretches[0]) { }
595 0 0 if ($s and $s->[1] > 1)
623 0 0 unless ref $_[0]
626 0 0 if $HTML::DOM::_Element::Debug > 2
630 0 0 if (($ptag = +($this = shift @to_do)->{'_tag'}) eq 'pre' or $ptag eq 'textarea' or $HTML::Tagset::isCDATA_Parent{$ptag})
636 0 0 if $HTML::DOM::_Element::Debug
639 0 0 unless $sibs = $this->{'_content'} and @$sibs
641 0 0 if (ref $sibs->[$i])
648 0 0 if $sibs->[$i] =~ /[^\n\r\f\t ]/s
651 0 0 if $HTML::DOM::_Element::Debug > 3
656 0 0 if ($i == 0) { }
0 0 elsif ($i == $#$sibs) { }
657 0 0 if (@$sibs == 1) { }
658 0 0 unless $HTML::DOM::_Element::canTighten{$ptag}
666 0 0 unless $HTML::DOM::_Element::canTighten{$ptag} or ref $sibs->[1] and $HTML::DOM::_Element::canTighten{$sibs->[1]{'_tag'}}
676 0 0 unless $HTML::DOM::_Element::canTighten{$ptag} or ref $$sibs[$i - 1] and $HTML::DOM::_Element::canTighten{$$sibs[$i - 1]{'_tag'}}
682 0 0 unless ref $$sibs[$i - 1] or ref $$sibs[$i + 1]
696 0 0 if ref $$sibs[$i - 1] and ref $$sibs[$i + 1] and not $HTML::DOM::_Element::canTighten{$$sibs[$i - 1]{'_tag'}} and not $HTML::DOM::_Element::canTighten{$$sibs[$i + 1]{'_tag'}}
702 0 0 if $HTML::DOM::_Element::Debug > 3
716 0 861 unless $tag
719 555 306 if (ref $tag) { }
725 306 0 if exists $self->{'_element_count'}
730 306 555 if $implicit
733 294 567 unless defined $pos
738 754 0 unless $self->_empty_element_map->{$tag} or $e->{'_empty_element'}
751 168 13739 if (wantarray) { }
761 0 0 if (wantarray) { }
776 0 0 unless defined $fh
777 0 0 unless defined $depth
779 0 0 $self->{'_implicit'} ? :
781 0 0 if (ref $_) { }
786 0 0 if (length $_ > 65 or /[\x00-\x1F]/) { }
789 0 0 length $_ <= 65 ? :
818 0 77 if (defined $indent and length $indent) { }
822 0 0 if (ref $node) { }
825 0 0 unless $node->can('starttag')
832 0 0 if ($start) { }
0 0 elsif (not $empty_element_map->{$tag} || $omissible_map->{$tag}) { }
833 0 0 if ($this_tag_tightenable = $HTML::DOM::_Element::canTighten{$tag} and not $nonindentable_ancestors and $last_tag_tightenable) { }
854 0 0 if $tag eq 'pre' or $HTML::Tagset::isCDATA_Parent{$tag}
864 0 0 if ($tag eq 'pre' or $HTML::Tagset::isCDATA_Parent{$tag}) { }
874 0 0 if ($this_tag_tightenable = $HTML::DOM::_Element::canTighten{$tag} and not $nonindentable_ancestors and $last_tag_tightenable) { }
907 0 0 unless defined $entities and not length $entities or $HTML::Tagset::isCDATA_Parent{$_[3]{'_tag'}} or $encoded_content
915 0 0 if ($nonindentable_ancestors) { }
919 0 0 if ($last_tag_tightenable) { }
951 339 59 if (ref $node) { }
955 176 163 if ($start) { }
162 1 elsif (not $empty_element_map->{$tag} || $omissible_map->{$tag}) { }
978 59 0 unless defined $entities and not length $entities or $HTML::Tagset::isCDATA_Parent{$_[3]{'_tag'}} or $encoded_content
993 0 77 if ($self->{'_store_declarations'} and defined $self->{'_decl'})
1009 0 98 if (not defined $pile[0]) { }
46 52 elsif (not ref $pile[0]) { }
1016 0 51 unless $this->{'_content'}
1017 51 1 unless ($tag = +($this = shift @pile)->{'_tag'}) eq 'style' or $tag eq 'script' or $skip_dels and $tag eq 'del'
1054 0 0 if (ref $node) { }
1056 0 0 if ($start) { }
1059 0 0 unless $attr eq '/' or $self->_valid_name($attr)
1064 0 0 if ($empty_element_map->{$tag} and not @{$nillio unless $node->{'_content'};}) { }
1065 0 0 unless $node->{'_content'}
1074 0 0 unless ($empty_element_map->{$tag} and not @{$nillio unless $node->{'_content'};})
1075 0 0 unless $node->{'_content'}
1100 0 0 if ($encoded_content) { }
1138 0 0 unless defined $list[-1]
1142 0 0 if $_ eq '_content' or $_ eq '_tag' or $_ eq '_parent' or $_ eq '/'
1149 0 0 if defined($val = $self->{$_})
1159 0 0 unless $self->{'_content'}
0 0 if (@{$nillio unless $self->{'_content'};}) { }
1163 0 0 if (ref $c) { }
1196 0 0 unless (defined $formatter)
1208 0 172 if $name eq '~literal'
1209 0 172 if $name eq '~declaration'
1210 0 172 if $name eq '~pi'
1212 0 172 if ($name eq '~comment')
1213 0 0 if (ref($self->{'text'} || '') eq 'ARRAY') { }
1225 0 172 $HTML::DOM::_Element::html_uc ? :
1228 654 14 if not length $_ or /^_/s or $_ eq '/'
1230 0 14 unless defined $val
1231 0 0 ref $HTML::DOM::_Element::boolean_attr{$name} ? :
0 14 if ($_ eq $val and exists $HTML::DOM::_Element::boolean_attr{$name} and ref $HTML::DOM::_Element::boolean_attr{$name} ? $HTML::DOM::_Element::boolean_attr{$name}{$_} : $HTML::DOM::_Element::boolean_attr{$name} eq $_) { }
1239 0 0 $HTML::DOM::_Element::html_uc ? :
1243 0 14 if (ref $val eq 'HTML::DOM::_Element' and $val->{'_tag'} eq '~literal') { }
1249 14 0 unless defined $entities and not length $entities or $encoded_content
1258 0 14 $HTML::DOM::_Element::html_uc ? :
1261 9 163 if (scalar $self->content_list == 0 and $self->_empty_element_map->{$self->tag}) { }
1278 0 0 if $name eq '~literal'
1279 0 0 if $name eq '~declaration'
1280 0 0 if $name eq '~pi'
1282 0 0 if ($name eq '~comment')
1283 0 0 if (ref($self->{'text'} || '') eq 'ARRAY') { }
1298 0 0 if not length $_ or /^_/s or $_ eq '/'
1302 0 0 unless defined($val = $self->{$_})
1306 0 0 @_ == 3 ? :
1310 0 162 $HTML::DOM::_Element::html_uc ? :
1349 0 477 unless ref $start
1352 0 477 unless defined $callback and ref $callback
1357 77 400 if (UNIVERSAL::isa($callback, 'CODE')) { }
400 0 elsif (UNIVERSAL::isa($callback, 'ARRAY')) { }
1362 0 400 if $c_pre and not UNIVERSAL::isa($c_pre, 'CODE')
1365 0 400 if $c_post and not UNIVERSAL::isa($c_post, 'CODE')
1368 0 400 unless $c_pre or $c_post
1373 0 0 unless ref $callback
1394 4584 4694 if (not defined $I[0] or ++$I[0] >= @{$C[0];})
1398 163 4421 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'};}) { }
1425 0 163 if (defined $rv and ref $rv eq $travsignal_package)
1427 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') { }
1461 4694 0 if ($c_pre)
1462 4635 59 if (defined $this and ref $this) { }
1472 0 59 if $ignore_text
1485 0 4694 if (not $rv) { }
0 4694 elsif (ref $rv eq $travsignal_package) { }
1490 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') { }
1497 0 0 if (ref $this and not $this->{'_empty_element'} || $$empty_element_map{$this->{'_tag'} or ''})
1537 4107 587 if (ref $this and not !(($content_r = $this->{'_content'}) && @$content_r) && ($this->{'_empty_element'} || $$empty_element_map{$this->{'_tag'} or ''}))
1560 0 1422 unless @_
1567 1027 5231 if (ref $_) { }
1568 87 940 if $_ eq $current
1571 95 5136 if $_ eq $current->{'_tag'}
1590 43 26 if ref $pc->[$i] and $pc->[$i] eq $self
1598 0 2 unless ref $_[0]
1603 0 1 unless @$pc
1604 0 1 if @$pc == 1
1606 0 1 if (wantarray) { }
1609 0 0 if ref $j and $j eq $_[0]
1615 1 0 $i ? :
1 1 if ref $pc->[$i] and $pc->[$i] eq $_[0]
1625 0 14 unless ref $_[0]
1630 0 8 unless @$pc
1631 1 7 if @$pc == 1
1633 0 7 if (wantarray) { }
1636 0 0 if ($seen) { }
1640 0 0 if ref $j and $j eq $_[0]
1643 0 0 unless $seen
1648 0 7 $i == $#$pc ? :
7 0 if ref $pc->[$i] and $pc->[$i] eq $_[0]
1659 22 11 if (@_ == 1) { }
1673 0 11 if (@stack and not length $stack[0]) { }
1678 0 11 unless 0 == shift @stack
1685 0 16 unless $here->{'_content'} and @{$here->{'_content'};} > $stack[0]
1689 0 16 if @stack and not ref $here
1737 400 0 if (wantarray) { }
1774 0 168 unless ref $pile[0]
1776 0 168 unless @_
1782 280 1165 if ($t eq $this_tag)
1783 241 39 if (wantarray) { }
1792 641 681 unless $this->{'_content'}
1794 99 30 if wantarray
1802 0 0 unless defined $attribute
1812 0 0 if (exists $_[0]{$attribute} and $_[0]{$attribute} eq $value)
1816 0 0 unless $wantarray
1826 0 0 if ($wantarray) { }
1830 0 0 unless @matching
1838 0 194 unless ref $_[0]
1842 0 355 unless defined $_[$i]
1844 18 337 if (ref $_[$i]) { }
1845 0 18 unless ref $_[$i] eq 'CODE'
1850 0 337 if $i == $#_
1851 173 164 ref $_[$i + 1] ? :
337 0 defined $_[$i + 1] ? :
1864 0 194 unless @criteria
1873 177 1446 if (ref $c eq 'CODE') { }
1874 157 20 unless &$c($this)
1879 1420 26 defined($val = $$this{$c->[0]}) ? :
1377 69 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]
1902 10 67 unless wantarray
1906 958 643 unless $this->{'_content'}
1908 33 151 if wantarray
1913 0 169 unless ref $_[0]
1917 0 169 unless defined $_[$i]
1919 0 169 if (ref $_[$i]) { }
1920 0 0 unless ref $_[$i] eq 'CODE'
1925 0 169 if $i == $#_
1926 0 169 ref $_[$i + 1] ? :
169 0 defined $_[$i + 1] ? :
1937 0 169 unless @criteria
1946 0 472 if (ref $c eq 'CODE') { }
1947 0 0 unless &$c($this)
1952 472 0 defined($val = $$this{$c->[0]}) ? :
337 135 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]
1973 105 30 unless wantarray
1977 64 303 unless defined($this = $this->{'_parent'}) and ref $this
1980 63 1 if wantarray
1987 0 0 if (@_ > 2) { }
1989 0 0 if grep((!defined($_)), @_)
1992 0 0 if (wantarray) { }
1996 0 0 exists $x->{$_} ? :
2004 0 0 if exists $x->{$attribute}
2014 0 0 unless defined $_[1]
2018 0 0 if (wantarray) { }
2020 0 0 exists $_->{$attribute} ? :
2025 0 0 if exists $x->{$attribute}
2034 0 0 unless ref $pile[0]
2039 0 0 unless defined($this_tag = +($this = shift @pile)->{'_tag'})
2043 0 0 unless $this->{'_content'}
2066 0 0 if $wantType and not $wantType{$tag}
2068 0 0 if (defined($link_attrs = $HTML::DOM::_Element::linkElements{$tag}))
2077 0 0 ref $link_attrs ? :
2078 0 0 if (defined($val = $self->attr($_)))
2098 0 0 if $_[0]{'_tag'} eq 'pre'
2099 0 0 unless $_[0]{'_content'}
2100 0 0 if (ref $it) { }
0 0 elsif ($pre) { }
2124 0 0 if $_[0]{'_tag'} eq 'pre'
2135 0 0 unless @_ == 2
2137 0 0 unless ref $h
2139 0 0 unless defined $i and ref $i
2144 0 0 if $h eq $i
2154 0 0 unless $h->{'_tag'} eq $i->{'_tag'}
2168 0 0 if length $_
2170 0 0 if length $_
2172 0 0 unless @keys_h == @keys_i
2178 0 0 unless $keys_h[$x] eq $keys_i[$x] and $$h{$keys_h[$x]} eq $$i{$keys_h[$x]}
2188 0 0 unless @$hcl == @$icl
2192 0 0 if (@$hcl)
2196 0 0 if (ref $hcl->[$x]) { }
2197 0 0 unless ref $icl->[$x]
2201 0 0 unless $hcl->[$x]->same_as($icl->[$x])
2204 0 0 if ref $icl->[$x]
2208 0 0 unless $hcl->[$x] eq $icl->[$x]
2232 0 0 unless @$lol
2234 0 0 if grep(($_ eq $lol), @ancestor_lols)
2242 0 0 if (ref $lol->[$i] eq 'ARRAY') { }
0 0 elsif (not ref $lol->[$i]) { }
0 0 elsif (ref $lol->[$i] eq 'HASH') { }
0 0 elsif (UNIVERSAL::isa($lol->[$i], 'HTML::DOM::_Element')) { }
2247 0 0 if ($i == 0) { }
2249 0 0 if $tag_name =~ m[[<>/\x00-\x20]]
2260 0 0 if defined $v and $k ne '_name' and $k ne '_content' and $k ne '_parent'
2270 0 0 if ($lol->[$i]{'_parent'}) { }
2293 0 0 if ($class eq 'HTML::DOM::_Element') { }
2294 0 0 if @attributes
2297 0 0 if (@children)
2300 0 0 if ref $c
2308 0 0 if ref $_
0 0 if @children
2318 0 0 if (wantarray) { }
2319 0 0 ref $_ eq 'ARRAY' ? :
2329 0 0 unless @_ == 1
2331 0 0 unless ref $_[0] eq 'ARRAY'
2348 0 0 if (ref $c) { }
2367 0 68 if ($_[0]{'_tag'} eq '~text')
2369 0 0 if ($_[0]{'_parent'}) { }
2376 0 0 if (ref $_[0] eq 'HTML::DOM::_Element') { }
2385 0 0 unless defined $old_node
2391 241 0 if (ref $c)
2392 106 135 if ($c->{'_tag'} eq '~text') { }
2394 0 106 if (ref $old_node eq 'HTML::DOM::_Element') { }
2424 0 0 unless defined $_[0]
2425 0 0 if $_[0] < 1 and $_[0] > -1
2426 0 0 if $_[0] <= -1
2434 0 0 unless defined $_[0]
2435 0 0 if $_[0] < 1 and $_[0] > -1
2436 0 0 if $_[0] <= -1
2462 0 0 if 0 == ($i = int($_[0] || 0))
2464 0 0 if $i <= -4000 or $i >= 4000
2467 0 0 if ($i < 0) { }
2476 0 0 if ($i >= 10)
2479 0 0 if ($x >= 10)
2482 0 0 if ($c >= 10)
2508 0 0 if (($tag = +($this = shift @stack)->{'_tag'}) eq 'ol') { }
0 0 elsif ($tag eq 'ul' or $tag eq 'dir' or $tag eq 'menu') { }
2512 0 0 ($this->{'start'} || '') =~ /^\s*(\d{1,7})\s*$/s ? :
2519 0 0 unless $this->{'_content'}
2520 0 0 unless ref $c
2522 0 0 if ($c->{'_tag'} eq 'li')
2525 0 0 if ($c->{'value'} || '') =~ /^\s*(\d{1,7})\s*$/s
2535 0 0 unless $this->{'_content'}
2536 0 0 unless ref $c
2538 0 0 if $c->{'_tag'} eq 'li'
2543 0 0 unless $this->{'_content'}
2544 0 0 if ref $c
2561 0 0 unless ref $c eq 'ARRAY'
2563 0 0 unless @$c
2565 0 0 unless defined $c->[$i]
2567 0 0 if (ref $c->[$i])
2568 0 0 if $c->[$i] eq $this
2572 0 0 if exists $parent_of{$c->[$i]}
2579 0 0 unless defined($p = $c->[$i]{'_parent'})
2580 0 0 unless ref $p
2582 0 0 unless $p eq $this
2599 0 0 if (defined($assert = $this->{'assert'}))
2602 0 0 unless (ref $assert)
2606 0 0 $assert =~ /\bsub\b/ ? :
2612 0 0 if ($@)
2624 0 0 $parent ? :
2628 0 0 if ($@) { }
0 0 elsif (not $rv) { }
2637 0 0 unless $this->{'_content'}
2648 0 0 unless my $attr = shift()
2651 0 0 unless $attr =~ /^$START_CHAR$NAME_CHAR+$/
2657 0 0 unless $_[0]{'_element_class'}