Branch Coverage

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


line true false branch
108 0 2151 unless defined $tag and length $tag
109 0 2151 if $tag =~ m[[<>/\x00-\x20]]
115 7 1154 unless defined $val
118 162 1989 if ($tag eq 'html')
127 1405 8488 if (@_) { }
128 1342 63 if (defined $_[0]) { }
144 1 8630 if (@_) { }
154 7 5541 if (@_) { }
155 0 0 if defined $_[0] and ref $_[0] and $self eq $_[0]
166 2250 3279 unless (shift())->{'_content'}
167 37 159 unless (shift())->{'_content'}
5529 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 1694 unless @_
285 0 1710 if (ref $_ eq 'ARRAY') { }
1163 547 elsif (ref $_) { }
292 44 1119 if $_->{'_parent'}
297 0 547 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 561 if @_ < 2
347 0 561 unless @_
354 561 0 if (@_ > 2) { }
356 0 563 if (ref $n eq 'ARRAY') { }
563 0 elsif (ref $n) { }
371 1 547 if ref $n
378 591 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 860 unless $tag
719 554 306 if (ref $tag) { }
725 306 0 if exists $self->{'_element_count'}
730 306 554 if $implicit
733 294 566 unless defined $pos
738 753 0 unless $self->_empty_element_map->{$tag} or $e->{'_empty_element'}
751 167 13703 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 ? :
819 0 77 if (defined $indent and length $indent) { }
823 0 0 if (ref $node) { }
826 0 0 unless $node->can('starttag')
833 0 0 if ($start) { }
0 0 elsif (not $empty_element_map->{$tag} || $omissible_map->{$tag}) { }
834 0 0 if ($this_tag_tightenable = $HTML::DOM::_Element::canTighten{$tag} and not $nonindentable_ancestors and $last_tag_tightenable) { }
855 0 0 if $tag eq 'pre' or $HTML::Tagset::isCDATA_Parent{$tag}
865 0 0 if ($tag eq 'pre' or $HTML::Tagset::isCDATA_Parent{$tag}) { }
875 0 0 if ($this_tag_tightenable = $HTML::DOM::_Element::canTighten{$tag} and not $nonindentable_ancestors and $last_tag_tightenable) { }
908 0 0 unless defined $entities and not length $entities or $HTML::Tagset::isCDATA_Parent{$_[3]{'_tag'}} or $encoded_content
916 0 0 if ($nonindentable_ancestors) { }
920 0 0 if ($last_tag_tightenable) { }
952 339 59 if (ref $node) { }
956 176 163 if ($start) { }
162 1 elsif (not $empty_element_map->{$tag} || $omissible_map->{$tag}) { }
979 59 0 unless defined $entities and not length $entities or $HTML::Tagset::isCDATA_Parent{$_[3]{'_tag'}} or $encoded_content
994 0 77 if ($self->{'_store_declarations'} and defined $self->{'_decl'})
1010 0 98 if (not defined $pile[0]) { }
46 52 elsif (not ref $pile[0]) { }
1017 0 51 unless $this->{'_content'}
1018 51 1 unless ($tag = ($this = shift @pile)->{'_tag'}) eq 'style' or $tag eq 'script' or $skip_dels and $tag eq 'del'
1055 0 0 if (ref $node) { }
1057 0 0 if ($start) { }
1060 0 0 unless $attr eq '/' or $self->_valid_name($attr)
1065 0 0 if ($empty_element_map->{$tag} and not @{$nillio unless $node->{'_content'};}) { }
1066 0 0 unless $node->{'_content'}
1075 0 0 unless ($empty_element_map->{$tag} and not @{$nillio unless $node->{'_content'};})
1076 0 0 unless $node->{'_content'}
1101 0 0 if ($encoded_content) { }
1139 0 0 unless defined $list[-1]
1143 0 0 if $_ eq '_content' or $_ eq '_tag' or $_ eq '_parent' or $_ eq '/'
1150 0 0 if defined($val = $self->{$_})
1161 0 0 unless $self->{'_content'}
0 0 if (@{$nillio unless $self->{'_content'};}) { }
1165 0 0 if (ref $c) { }
1199 0 0 unless (defined $formatter)
1211 0 172 if $name eq '~literal'
1212 0 172 if $name eq '~declaration'
1213 0 172 if $name eq '~pi'
1215 0 172 if ($name eq '~comment')
1216 0 0 if (ref($self->{'text'} || '') eq 'ARRAY') { }
1228 0 172 $HTML::DOM::_Element::html_uc ? :
1231 654 14 if not length $_ or /^_/s or $_ eq '/'
1233 0 14 unless defined $val
1234 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 $_) { }
1242 0 0 $HTML::DOM::_Element::html_uc ? :
1246 0 14 if (ref $val eq 'HTML::DOM::_Element' and $val->{'_tag'} eq '~literal') { }
1252 14 0 unless defined $entities and not length $entities or $encoded_content
1261 0 14 $HTML::DOM::_Element::html_uc ? :
1264 9 163 if (scalar $self->content_list == 0 and $self->_empty_element_map->{$self->tag}) { }
1281 0 0 if $name eq '~literal'
1282 0 0 if $name eq '~declaration'
1283 0 0 if $name eq '~pi'
1285 0 0 if ($name eq '~comment')
1286 0 0 if (ref($self->{'text'} || '') eq 'ARRAY') { }
1301 0 0 if not length $_ or /^_/s or $_ eq '/'
1305 0 0 unless defined($val = $self->{$_})
1309 0 0 @_ == 3 ? :
1313 0 162 $HTML::DOM::_Element::html_uc ? :
1352 0 476 unless ref $start
1355 0 476 unless defined $callback and ref $callback
1360 77 399 if (UNIVERSAL::isa($callback, 'CODE')) { }
399 0 elsif (UNIVERSAL::isa($callback, 'ARRAY')) { }
1365 0 399 if $c_pre and not UNIVERSAL::isa($c_pre, 'CODE')
1368 0 399 if $c_post and not UNIVERSAL::isa($c_post, 'CODE')
1371 0 399 unless $c_pre or $c_post
1376 0 0 unless ref $callback
1397 4565 4676 if (not defined $I[0] or ++$I[0] >= @{$C[0];})
1401 163 4402 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'};}) { }
1428 0 163 if (defined $rv and ref $rv eq $travsignal_package)
1430 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') { }
1464 4676 0 if ($c_pre)
1465 4617 59 if (defined $this and ref $this) { }
1475 0 59 if $ignore_text
1488 0 4676 if (not $rv) { }
0 4676 elsif (ref $rv eq $travsignal_package) { }
1493 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') { }
1500 0 0 if (ref $this and not $this->{'_empty_element'} || $$empty_element_map{$this->{'_tag'} or ''})
1540 4089 587 if (ref $this and not !(($content_r = $this->{'_content'}) && @$content_r) && ($this->{'_empty_element'} || $$empty_element_map{$this->{'_tag'} or ''}))
1563 0 1421 unless @_
1570 1027 5219 if (ref $_) { }
1571 87 940 if $_ eq $current
1574 95 5124 if $_ eq $current->{'_tag'}
1593 43 26 if ref $pc->[$i] and $pc->[$i] eq $self
1601 0 2 unless ref $_[0]
1606 0 1 unless @$pc
1607 0 1 if @$pc == 1
1609 0 1 if (wantarray) { }
1612 0 0 if ref $j and $j eq $_[0]
1618 1 0 $i ? :
1 1 if ref $pc->[$i] and $pc->[$i] eq $_[0]
1628 0 14 unless ref $_[0]
1633 0 8 unless @$pc
1634 1 7 if @$pc == 1
1636 0 7 if (wantarray) { }
1639 0 0 if ($seen) { }
1643 0 0 if ref $j and $j eq $_[0]
1646 0 0 unless $seen
1651 0 7 $i == $#$pc ? :
7 0 if ref $pc->[$i] and $pc->[$i] eq $_[0]
1662 22 11 if (@_ == 1) { }
1676 0 11 if (@stack and not length $stack[0]) { }
1681 0 11 unless 0 == shift @stack
1688 0 16 unless $here->{'_content'} and @{$here->{'_content'};} > $stack[0]
1692 0 16 if @stack and not ref $here
1740 399 0 if (wantarray) { }
1777 0 167 unless ref $pile[0]
1779 0 167 unless @_
1785 274 1155 if ($t eq $this_tag)
1786 235 39 if (wantarray) { }
1795 633 673 unless $this->{'_content'}
1797 98 30 if wantarray
1805 0 0 unless defined $attribute
1815 0 0 if (exists $_[0]{$attribute} and $_[0]{$attribute} eq $value)
1819 0 0 unless $wantarray
1829 0 0 if ($wantarray) { }
1833 0 0 unless @matching
1841 0 190 unless ref $_[0]
1845 0 347 unless defined $_[$i]
1847 18 329 if (ref $_[$i]) { }
1848 0 18 unless ref $_[$i] eq 'CODE'
1853 0 329 if $i == $#_
1854 169 160 ref $_[$i + 1] ? :
329 0 defined $_[$i + 1] ? :
1867 0 190 unless @criteria
1876 177 1408 if (ref $c eq 'CODE') { }
1877 157 20 unless &$c($this)
1882 1382 26 defined($val = $$this{$c->[0]}) ? :
1339 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]
1905 10 67 unless wantarray
1909 936 627 unless $this->{'_content'}
1911 33 147 if wantarray
1916 0 168 unless ref $_[0]
1920 0 168 unless defined $_[$i]
1922 0 168 if (ref $_[$i]) { }
1923 0 0 unless ref $_[$i] eq 'CODE'
1928 0 168 if $i == $#_
1929 0 168 ref $_[$i + 1] ? :
168 0 defined $_[$i + 1] ? :
1940 0 168 unless @criteria
1949 0 465 if (ref $c eq 'CODE') { }
1950 0 0 unless &$c($this)
1955 465 0 defined($val = $$this{$c->[0]}) ? :
331 134 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]
1976 105 29 unless wantarray
1980 63 297 unless defined($this = $this->{'_parent'}) and ref $this
1983 62 1 if wantarray
1990 0 0 if (@_ > 2) { }
1992 0 0 if grep((!defined($_)), @_)
1995 0 0 if (wantarray) { }
1999 0 0 exists $x->{$_} ? :
2007 0 0 if exists $x->{$attribute}
2017 0 0 unless defined $_[1]
2021 0 0 if (wantarray) { }
2023 0 0 exists $_->{$attribute} ? :
2028 0 0 if exists $x->{$attribute}
2037 0 0 unless ref $pile[0]
2042 0 0 unless defined($this_tag = ($this = shift @pile)->{'_tag'})
2046 0 0 unless $this->{'_content'}
2069 0 0 if $wantType and not $wantType{$tag}
2071 0 0 if (defined($link_attrs = $HTML::DOM::_Element::linkElements{$tag}))
2080 0 0 ref $link_attrs ? :
2081 0 0 if (defined($val = $self->attr($_)))
2101 0 0 if $_[0]{'_tag'} eq 'pre'
2102 0 0 unless $_[0]{'_content'}
2103 0 0 if (ref $it) { }
0 0 elsif ($pre) { }
2127 0 0 if $_[0]{'_tag'} eq 'pre'
2138 0 0 unless @_ == 2
2140 0 0 unless ref $h
2142 0 0 unless defined $i and ref $i
2147 0 0 if $h eq $i
2157 0 0 unless $h->{'_tag'} eq $i->{'_tag'}
2171 0 0 if length $_
2173 0 0 if length $_
2175 0 0 unless @keys_h == @keys_i
2181 0 0 unless $keys_h[$x] eq $keys_i[$x] and $$h{$keys_h[$x]} eq $$i{$keys_h[$x]}
2191 0 0 unless @$hcl == @$icl
2195 0 0 if (@$hcl)
2199 0 0 if (ref $hcl->[$x]) { }
2200 0 0 unless ref $icl->[$x]
2204 0 0 unless $hcl->[$x]->same_as($icl->[$x])
2207 0 0 if ref $icl->[$x]
2211 0 0 unless $hcl->[$x] eq $icl->[$x]
2235 0 0 unless @$lol
2237 0 0 if grep(($_ eq $lol), @ancestor_lols)
2245 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')) { }
2250 0 0 if ($i == 0) { }
2252 0 0 if $tag_name =~ m[[<>/\x00-\x20]]
2263 0 0 if defined $v and $k ne '_name' and $k ne '_content' and $k ne '_parent'
2273 0 0 if ($lol->[$i]{'_parent'}) { }
2296 0 0 if ($class eq 'HTML::DOM::_Element') { }
2297 0 0 if @attributes
2300 0 0 if (@children)
2303 0 0 if ref $c
2311 0 0 if ref $_
0 0 if @children
2321 0 0 if (wantarray) { }
2322 0 0 ref $_ eq 'ARRAY' ? :
2332 0 0 unless @_ == 1
2334 0 0 unless ref $_[0] eq 'ARRAY'
2351 0 0 if (ref $c) { }
2370 0 68 if ($_[0]{'_tag'} eq '~text')
2372 0 0 if ($_[0]{'_parent'}) { }
2379 0 0 if (ref $_[0] eq 'HTML::DOM::_Element') { }
2388 0 0 unless defined $old_node
2394 241 0 if (ref $c)
2395 106 135 if ($c->{'_tag'} eq '~text') { }
2397 0 106 if (ref $old_node eq 'HTML::DOM::_Element') { }
2427 0 0 unless defined $_[0]
2428 0 0 if $_[0] < 1 and $_[0] > -1
2429 0 0 if $_[0] <= -1
2437 0 0 unless defined $_[0]
2438 0 0 if $_[0] < 1 and $_[0] > -1
2439 0 0 if $_[0] <= -1
2465 0 0 if 0 == ($i = int($_[0] || 0))
2467 0 0 if $i <= -4000 or $i >= 4000
2470 0 0 if ($i < 0) { }
2479 0 0 if ($i >= 10)
2482 0 0 if ($x >= 10)
2485 0 0 if ($c >= 10)
2511 0 0 if (($tag = ($this = shift @stack)->{'_tag'}) eq 'ol') { }
0 0 elsif ($tag eq 'ul' or $tag eq 'dir' or $tag eq 'menu') { }
2515 0 0 ($this->{'start'} || '') =~ /^\s*(\d{1,7})\s*$/s ? :
2522 0 0 unless $this->{'_content'}
2523 0 0 unless ref $c
2525 0 0 if ($c->{'_tag'} eq 'li')
2528 0 0 if ($c->{'value'} || '') =~ /^\s*(\d{1,7})\s*$/s
2538 0 0 unless $this->{'_content'}
2539 0 0 unless ref $c
2541 0 0 if $c->{'_tag'} eq 'li'
2546 0 0 unless $this->{'_content'}
2547 0 0 if ref $c
2564 0 0 unless ref $c eq 'ARRAY'
2566 0 0 unless @$c
2568 0 0 unless defined $c->[$i]
2570 0 0 if (ref $c->[$i])
2571 0 0 if $c->[$i] eq $this
2575 0 0 if exists $parent_of{$c->[$i]}
2582 0 0 unless defined($p = $c->[$i]{'_parent'})
2583 0 0 unless ref $p
2585 0 0 unless $p eq $this
2602 0 0 if (defined($assert = $this->{'assert'}))
2605 0 0 unless (ref $assert)
2609 0 0 $assert =~ /\bsub\b/ ? :
2615 0 0 if ($@)
2627 0 0 $parent ? :
2631 0 0 if ($@) { }
0 0 elsif (not $rv) { }
2640 0 0 unless $this->{'_content'}
2651 0 0 unless my $attr = shift()
2654 0 0 unless $attr =~ /^$START_CHAR$NAME_CHAR+$/
2660 0 0 unless $_[0]{'_element_class'}