lib/HTML/Object/DOM/Space.pm

filter: Statementstmt 63.0% 29 / 46 Branchbran 30.0% 3 / 10 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 48.0% 12 / 25 Podpod 100% 18 / 18 totaltotal 60.7% 62 / 102 CC 7 SCAR 14.5
CC
7
Cov
55%
isEqualNode
20.0
getAttributes
6.0
init
2.0
CRAP 4.3
« lib/HTML/Object/DOM/Element/Link.pm ↑ Summary blib/lib/HTML/Object/DOM/Element/Output.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/DOM/Space.pm
3 ## Version v0.2.0_1
4 ## Copyright(c) 2022 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/12/13
7 ## Modified 2026/03/29
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::Space;
15 BEGIN
16 {
17 32 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 32 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 32 ▶ warnings::register_categories( 'HTML::Object' );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 32 ▶ use parent qw( HTML::Object::Space HTML::Object::DOM::CharacterData );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 32 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 32 our $VERSION = 'v0.2.0_1';
23 };
24  
25 32 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 32 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 sub init
29 {
30 441 ▶ my $self = shift( @_ );
Subroutine init: called CC=2 SCAR=7.0
Pod documented
31 441 $self->{_init_strict_use_sub} = 1;
32 441 ▶ $self->HTML::Object::Space::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->HTML::Object::Space::init(@_) or return $self->pass_error 0 441 441
33 441 return( $self );
34 }
35  
36 0 ▶sub getAttributes { return( wantarray() ? () : [] ); }
Subroutine getAttributes: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
37  
38 586 ▶sub getChildNodes { return( wantarray() ? () : [] ); }
Subroutine getChildNodes: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 462 124 586
39  
40 0 ▶sub getElementById { return; }
Subroutine getElementById: not called CC=1 SCAR=6.9
Pod documented
41  
42 0 ▶sub getFirstChild { return; }
Subroutine getFirstChild: not called CC=1 SCAR=6.9
Pod documented
43  
44 0 ▶sub getLastChild { return; }
Subroutine getLastChild: not called CC=1 SCAR=6.9
Pod documented
45  
46 0 ▶sub getRootNode { return( shift->parent->getRootNode ); }
Subroutine getRootNode: not called CC=1 SCAR=6.9
Pod documented
47  
48 0 ▶sub isAttributeNode { return(0); }
Subroutine isAttributeNode: not called CC=1 SCAR=6.9
Pod documented
49  
50 0 ▶sub isCommentNode { return(0); }
Subroutine isCommentNode: not called CC=1 SCAR=6.9
Pod documented
51  
52 465 ▶sub isElementNode { return(0); }
Subroutine isElementNode: called CC=1 SCAR=0.0
Pod documented
53  
54 0 ▶sub isNamespaceNode { return(0); }
Subroutine isNamespaceNode: not called CC=1 SCAR=6.9
Pod documented
55  
56 0 ▶sub isPINode { return(0); }
Subroutine isPINode: not called CC=1 SCAR=6.9
Pod documented
57  
58 0 ▶sub isProcessingInstructionNode { return(0); }
Subroutine isProcessingInstructionNode: not called CC=1 SCAR=6.9
Pod documented
59  
60 0 ▶sub isTextNode { return(0); }
Subroutine isTextNode: not called CC=1 SCAR=6.9
Pod documented
61  
62 sub isEqualNode
63 {
64 0 ▶ my $self = shift( @_ );
Subroutine isEqualNode: not called CC=4 SCAR=30.0
Pod documented
65 0 ▶ my $e = shift( @_ ) || return( $self->error( "No html element was provided to insert." ) );
Condition0%0/2
shift @_ || (return $self->error('No html element was provided to insert.'))
l!l
00
MC/DC0%0/1
shift @_ || (return $self->error('No html element was provided to insert.'))
shift @_
Truth table0%0/2
A
A= shift @_
Aresult
11
00
66 0 ▶ return( $self->error( "Element provided (", overload::StrVal( $e ), ") is not an HTML::Object::Element." ) ) if( !$self->_is_a( $e => 'HTML::Object::Element' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_a($e, "HTML::Object::Element") 0 0 0
67 0 ▶ return(0) if( !$self->_is_a( $e => 'HTML::Object::Space' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_a($e, "HTML::Object::Space") 0 0 0
68 0 return( $self->value eq $e->value );
69 }
70  
71 # Note: Property
72 0 ▶sub nodeValue : lvalue { return( shift->_set_get_lvalue( 'value', @_ ) ); }
Subroutine nodeValue: not called CC=1 SCAR=6.9
Pod documented
73  
74 sub parent { return( shift->_set_get_object_without_init({
75 970 ▶ field => 'parent',
Subroutine parent: called CC=1 SCAR=0.0
Pod documented
76 weaken => 1,
77 }, 'HTML::Object::DOM::Node', @_ ) ); }
78  
79 248 ▶sub string_value { return( shift->value ); }
Subroutine string_value: called CC=1 SCAR=0.0
Pod documented
80  
81 32 1;
82 # NOTE: POD
83 __END__
84  
85 =encoding utf-8
86  
87 =head1 NAME
88  
89 HTML::Object::DOM::Space - HTML Object DOM Space Class
90  
91 =head1 SYNOPSIS
92  
93 use HTML::Object::DOM::Space;
94 my $sp = HTML::Object::DOM::Space->new( value => $some_space ) ||
95 die( HTML::Object::DOM::Space->error, "\n" );
96  
97 =head1 VERSION
98  
99 v0.2.0_1
100  
101 =head1 DESCRIPTION
102  
103 This implements the representation of a space-only chunk of data. This is a divergence from the DOM standard which treats space as text. Thus, any data chunk comprised only of spaces between tags would all be space nodes. Spaces includes space, tabulation, carriage return, new line, and any other horizontal and vertical spaces.
104  
105 It inherits from L<HTML::Object::Space> and L<HTML::Object::DOM::CharacterData>
106  
107 =head1 INHERITANCE
108  
109 +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------------+ +--------------------------+
110 | HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::CharacterData | --> | HTML::Object::DOM::Space |
111 +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------------+ +--------------------------+
112 | ^
113 | |
114 v |
115 +-----------------------+ |
116 | HTML::Object::Space | -----------------------------------------------------------------------------------------------------------------+
117 +-----------------------+
118  
119 =head1 PROPERTIES
120  
121 =head2 nodeValue
122  
123 Sets or gets the value of this space node.
124  
125 =head1 METHODS
126  
127 =head2 getAttributes
128  
129 Returns an empty list in list context or an empty array reference in scalar context.
130  
131 =head2 getChildNodes
132  
133 Returns an empty list in list context or an empty array reference in scalar context.
134  
135 =head2 getElementById
136  
137 Returns an empty list in list context or C<undef> in scalar context.
138  
139 =head2 getFirstChild
140  
141 Returns an empty list in list context or C<undef> in scalar context.
142  
143 =head2 getLastChild
144  
145 Returns an empty list in list context or C<undef> in scalar context.
146  
147 =head2 getRootNode
148  
149 Returns the value from the parent's C<getRootNode>
150  
151 =head2 isAttributeNode
152  
153 Returns false.
154  
155 =head2 isCommentNode
156  
157 Returns false.
158  
159 =head2 isElementNode
160  
161 Returns false.
162  
163 =head2 isNamespaceNode
164  
165 Returns false.
166  
167 =head2 isPINode
168  
169 Returns false.
170  
171 =head2 isProcessingInstructionNode
172  
173 Returns false.
174  
175 =head2 isTextNode
176  
177 Returns false.
178  
179 =head2 isEqualNode
180  
181 Returns true if both nodes are space nodes of equivalent value.
182  
183 =head2 parent
184  
185 Sets or gets the object value of this space node's parent.
186  
187 =head2 string_value
188  
189 Read-only.
190  
191 Returns the value of this space node.
192  
193 =head1 AUTHOR
194  
195 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
196  
197 =head1 SEE ALSO
198  
199 L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Whitespace>
200  
201 =head1 COPYRIGHT & LICENSE
202  
203 Copyright(c) 2021 DEGUEST Pte. Ltd.
204  
205 All rights reserved
206  
207 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
208  
209 =cut
« lib/HTML/Object/DOM/Element/Link.pm ↑ Summary blib/lib/HTML/Object/DOM/Element/Output.pm »