lib/HTML/Object/DOM/DocumentFragment.pm

filter: Statementstmt 47.8% 22 / 46 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 8 / 24 Podpod 100% 13 / 13 totaltotal 50.5% 43 / 85 CC 2 SCAR 6.9
CC
2
Cov
46%
_element_method
6.0
append
2.0
as_string
2.0
CRAP 2.0
« blib/lib/HTML/Object/XPath/Variable.pm ↑ Summary lib/HTML/Object/Comment.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/DOM/DocumentFragment.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/12/20
7 ## Modified 2022/09/18
8 ## All rights reserved.
9 ##
10 ##
11 ## This program is free software; you can redistribute it and/or modify it
12 ## under the same terms as Perl itself.
13 ##----------------------------------------------------------------------------
14 package HTML::Object::DOM::DocumentFragment;
15 BEGIN
16 {
17 2 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶ warnings::register_categories( 'HTML::Object' );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶ use parent qw( HTML::Object::DOM::Node );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 our $VERSION = 'v0.2.0';
23 };
24  
25 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 0 ▶sub append { return( shift->_element_method( 'append', @_ ) ); }
Subroutine append: not called CC=1 SCAR=6.9
Pod documented
29  
30 sub as_string
31 {
32 0 ▶ my $self = shift( @_ );
Subroutine as_string: not called CC=1 SCAR=6.9
Pod documented
33 0 my $a = $self->new_array;
34 # We get the string version of all of our children, except ourself, since a
35 # document fragment is transparent; has no impact on the dom tree.
36 $self->children->foreach(sub
37 {
38 0 ▶ $a->push( $_->as_string );
Subroutine __ANON__: not called CC=1 SCAR=6.9
39 0 });
40 0 return( $a->join( '' )->scalar );
41 }
42  
43 # Note: Property
44 0 ▶sub childElementCount { return( shift->_elements->length ); }
Subroutine childElementCount: not called CC=1 SCAR=6.9
Pod documented
45  
46 # Note: Property
47 0 ▶sub firstElementChild { return( shift->_elements->first ); }
Subroutine firstElementChild: not called CC=1 SCAR=6.9
Pod documented
48  
49 0 ▶sub getElementById { return( shift->_element_method( 'getElementById', @_ ) ); }
Subroutine getElementById: not called CC=1 SCAR=6.9
Pod documented
50  
51 # Note: Property
52 0 ▶sub lastElementChild { return( shift->_elements->last ); }
Subroutine lastElementChild: not called CC=1 SCAR=6.9
Pod documented
53  
54 2 ▶sub parent { return; }
Subroutine parent: called CC=1 SCAR=0.0
Pod documented
55  
56 0 ▶sub parentNode { return; }
Subroutine parentNode: not called CC=1 SCAR=6.9
Pod documented
57  
58 0 ▶sub parentElement { return; }
Subroutine parentElement: not called CC=1 SCAR=6.9
Pod documented
59  
60 0 ▶sub prepend { return( shift->_element_method( 'prepend', @_ ) ); }
Subroutine prepend: not called CC=1 SCAR=6.9
Pod documented
61  
62 0 ▶sub querySelector { return( shift->_element_method( 'querySelector', @_ ) ); }
Subroutine querySelector: not called CC=1 SCAR=6.9
Pod documented
63  
64 0 ▶sub querySelectorAll { return( shift->_element_method( 'querySelectorAll', @_ ) ); }
Subroutine querySelectorAll: not called CC=1 SCAR=6.9
Pod documented
65  
66 0 ▶sub replaceChildren { return( shift->_element_method( 'replaceChildren', @_ ) ); }
Subroutine replaceChildren: not called CC=1 SCAR=6.9
Pod documented
67  
68 0 ▶sub _elements { return( shift->children->filter(sub{ $_->isElementNode }) ); }
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine _elements: not called CC=1 SCAR=6.9
69  
70 sub _element_method
71 {
72 0 ▶ my $self = shift( @_ );
Subroutine _element_method: not called CC=2 SCAR=17.9
73 0 my $meth = shift( @_ );
74 0 require HTML::Object::DOM::Element;
75 0 my $code = HTML::Object::DOM::Element->can( $meth );
76 0 ▶ return( $self->error( "Unknown method \"$meth\" in HTML::Object::DOM::Element" ) ) if( !$code );
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 0 0
77 0 return( $self->$code( @_ ) );
78 }
79  
80 2 1;
81 # NOTE: POD
82 __END__
« blib/lib/HTML/Object/XPath/Variable.pm ↑ Summary lib/HTML/Object/Comment.pm »