lib/HTML/Object/DOM/Element/Shared.pm

filter: Statementstmt 45.8% 60 / 131 Branchbran 30.0% 6 / 20 Conditioncond 20.0% 2 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 35.3% 29 / 82 Podpod 80.0% 60 / 75 totaltotal 48.4% 157 / 324 CC 15 SCAR 12.8
CC
15
Cov
42%
labels
20.0
list
20.0
form
7.5
CRAP 3.6
« blib/lib/HTML/Object/DOM/Space.pm ↑ Summary lib/HTML/Object/DOM/Element/FieldSet.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/DOM/Element/Shared.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/12/25
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::Element::Shared;
15 BEGIN
16 {
17 25 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 25 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 25 ▶ warnings::register_categories( 'HTML::Object' );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 25 ▶ use vars qw( @EXPORT_OK %EXPORT_TAGS $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 25 ▶ use Exporter qw( import );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 25 our @EXPORT_OK = qw(
23 accept accessKey align allowdirs alt autocapitalize autocomplete autofocus checked checkValidity compact crossOrigin currentSrc defaultChecked defaultValue dirName disabled download files form formAction formEnctype formMethod formNoValidate formTarget hash height host hostname href hreflang indeterminate inputmode labels list max maxLength min minLength multiple name origin password pathname pattern placeholder port protocol readOnly referrerPolicy rel relList reportValidity required selectionDirection selectionEnd selectionStart search setCustomValidity size src step target type useMap username value validationMessage validity valueAsDate valueAsNumber webkitdirectory webkitEntries willValidate width
24 );
25 25 our %EXPORT_TAGS = (
26 anchor => [qw( download hash host hostname href hreflang origin password pathname port protocol referrerPolicy rel relList search target username )],
27 area => [qw( accessKey alt download hash host hostname href hreflang origin password pathname port protocol referrerPolicy rel relList search target username )],
28 base => [qw( href target )],
29 button => [qw(
30 form formAction formEnctype formMethod formNoValidate formTarget
31 accessKey autofocus disabled form labels name type validationMessage validity value willValidate
32 )],
33 canvas => [qw( height width )],
34 caption => [qw( align )],
35 dir => [qw( compact )],
36 div => [qw( align )],
37 dl => [qw( compact )],
38 embed => [qw( align height name src width )],
39 fencedframe => [qw( height width )],
40 fieldset => [qw( disabled checkValidity form name reportValidity setCustomValidity validationMessage validity willValidate )],
41 form => [qw(
42 accept autocapitalize autocomplete name
43
44 checkValidity reportValidity
45 )],
46 heading => [qw( align )],
47 hr => [qw( align size width )],
48 iframe => [qw( align height name referrerPolicy src width )],
49 img => [qw( alt crossOrigin currentSrc height referrerPolicy src useMap width )],
50 input => [qw(
51 accept accessKey align allowdirs alt autocapitalize autocomplete autofocus checked
52 defaultChecked defaultValue dirName disabled files form
53 formAction formEnctype formMethod formNoValidate formTarget height indeterminate
54 inputmode labels list max maxLength min minLength multiple name pattern placeholder
55 readOnly required selectionDirection selectionEnd selectionStart size src step
56 type useMap validationMessage validity value valueAsDate valueAsNumber
57 webkitEntries webkitdirectory width willValidate
58 )],
59 label => [qw( form )],
60 legend => [qw( accessKey align form )],
61 li => [qw( type value )],
62 'link' => [qw( crossOrigin disabled href hreflang referrerPolicy rel relList type )],
63 'map' => [qw( name )],
64 marquee => [qw( height width )],
65 media => [qw( crossOrigin currentSrc src )],
66 menu => [qw( compact type )],
67 meter => [qw( labels max min value )],
68 object => [qw( align checkValidity height name setCustomValidity type useMap validity validationMessage width willValidate )],
69 ol => [qw( compact type )],
70 optgroup => [qw( disabled )],
71 option => [qw( disabled form )],
72 output => [qw( checkValidity form labels setCustomValidity type validity validationMessage value willValidate )],
73 paragraph => [qw( align )],
74 param => [qw( name type value )],
75 pre => [qw( width )],
76 progress => [qw( labels value )],
77 script => [qw( crossOrigin src referrerPolicy type )],
78 'select' => [qw( checkValidity disabled form labels name reportValidity required setCustomValidity type validationMessage validity value willValidate )],
79 slot => [qw( name )],
80 source => [qw( src type )],
81 style => [qw( disabled type )],
82 table => [qw( align width )],
83 tablecaption => [qw( align )],
84 tablecell => [qw( align height width )],
85 tablecol => [qw( align width )],
86 tablerow => [qw( align )],
87 tablesection => [qw( align )],
88 track => [qw( src )],
89 ulist => [qw( compact type )],
90 video => [qw( height width )],
91 );
92 25 $EXPORT_TAGS{all} = [@EXPORT_OK];
93 25 our $VERSION = 'v0.2.0';
94 };
95  
96 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
97 25 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
98  
99 # Note: property for input
100 0 ▶sub accept : lvalue { return( shift->_set_get_property( 'accept', @_ ) ); }
Subroutine accept: not called CC=1 SCAR=6.9
Pod documented
101  
102 # Note: property for input
103 0 ▶sub accessKey : lvalue { return( shift->_set_get_property( 'accesskey', @_ ) ); }
Subroutine accessKey: not called CC=1 SCAR=6.9
Pod documented
104  
105 # Note: property for embed
106 0 ▶sub align : lvalue { return( shift->_set_get_property( 'align', @_ ) ); }
Subroutine align: not called CC=1 SCAR=6.9
Pod undocumented
107  
108 # Note: property for input
109 0 ▶sub allowdirs : lvalue { return( shift->_set_get_boolean( 'allowdirs', @_ ) ); }
Subroutine allowdirs: not called CC=1 SCAR=6.9
Pod documented
110  
111 # Note: property for img, input
112 0 ▶sub alt : lvalue { return( shift->_set_get_property( 'alt', @_ ) ); }
Subroutine alt: not called CC=1 SCAR=6.9
Pod documented
113  
114 # Note: property for input
115 0 ▶sub autocapitalize : lvalue { return( shift->_set_get_property( 'autocapitalize', @_ ) ); }
Subroutine autocapitalize: not called CC=1 SCAR=6.9
Pod documented
116  
117 # Note: property for input
118 0 ▶sub autocomplete : lvalue { return( shift->_set_get_property( 'autocomplete', @_ ) ); }
Subroutine autocomplete: not called CC=1 SCAR=6.9
Pod documented
119  
120 # Note: property for input
121 0 ▶sub autofocus : lvalue { return( shift->_set_get_property( { attribute => 'autofocus', is_boolean => 1 }, @_ ) ); }
Subroutine autofocus: not called CC=1 SCAR=6.9
Pod documented
122  
123 # Note: property boolean for input
124 0 ▶sub checked : lvalue { return( shift->_set_get_property( { attribute => 'checked', is_boolean => 1 }, @_ ) ); }
Subroutine checked: not called CC=1 SCAR=6.9
Pod documented
125  
126 # Note: method
127 0 ▶sub checkValidity { return( shift->_set_get_boolean( 'checkValidity', @_ ) ); }
Subroutine checkValidity: not called CC=1 SCAR=6.9
Pod documented
128  
129 # Note: property
130 0 ▶sub compact : lvalue { return( shift->_set_get_property( { attribute => 'compact', is_boolean => 1 }, @_ ) ); }
Subroutine compact: not called CC=1 SCAR=6.9
Pod undocumented
131  
132 # Note: property
133 0 ▶sub crossOrigin : lvalue { return( shift->_set_get_property( 'crossorigin', @_ ) ); }
Subroutine crossOrigin: not called CC=1 SCAR=6.9
Pod documented
134  
135 # Note: property
136 0 ▶sub currentSrc : lvalue { return( shift->_set_get_property( 'currentsrc', @_ ) ); }
Subroutine currentSrc: not called CC=1 SCAR=6.9
Pod undocumented
137  
138 # Note: property boolean for input
139 0 ▶sub defaultChecked : lvalue { return( shift->_set_get_property( { attribute => 'defaultchecked', is_boolean => 1 }, @_ ) ); }
Subroutine defaultChecked: not called CC=1 SCAR=6.9
Pod documented
140  
141 # Note: property for input
142 0 ▶sub defaultValue : lvalue { return( shift->_set_get_property( 'value', @_ ) ); }
Subroutine defaultValue: not called CC=1 SCAR=6.9
Pod undocumented
143  
144 # Note: property for input
145 0 ▶sub dirName { return( shift->_set_get_scalar_as_object( 'dirName', @_ ) ); }
Subroutine dirName: not called CC=1 SCAR=6.9
Pod documented
146  
147 # Note: property for input
148 1 ▶sub disabled : lvalue { return( shift->_set_get_property( { attribute => 'disabled', is_boolean => 1 }, @_ ) ); }
Subroutine disabled: called CC=1 SCAR=0.0
Pod documented
149  
150 # Note: property for anchor, area
151 2 ▶sub download : lvalue { return( shift->_set_get_property( 'download', @_ ) ); }
Subroutine download: called CC=1 SCAR=0.0
Pod undocumented
152  
153 # Note: property for input
154 0 ▶sub files { return( shift->_set_get_object( 'files', 'HTML::Object::DOM::FileList' ) ); }
Subroutine files: not called CC=1 SCAR=6.9
Pod documented
155  
156 # Note: property read-only
157 sub form
158 {
159 1 ▶ my $self = shift( @_ );
Subroutine form: called CC=4 SCAR=20.1
Pod documented
160 # If the element has a 'form' attribute containing the form it, we use it to find the specific form, otherwise we search for the parent form
161 1 my $id = $self->attr( 'form' );
162 1 ▶ if( defined( $id ) && CORE::length( "$id" ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $id and length "$id") { } 0 1 1
Condition33%1/3
defined $id and length "$id"
!ll&&!rl&&r
100
MC/DC0%0/2
defined $id and length "$id"
defined $id length "$id"
Truth table33%1/3
A and B
A= defined $idB= length "$id"
ABresult
0X0
100
111
163 {
164 0 my $root = $self->root;
165 0 ▶ return if( !defined( $root ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $root 0 0 0
166 # my $form = $root->getElementById( $id );
167 0 my $forms = $root->look_down( _tag => 'form', id => $id );
168 0 return( $forms->first );
169 }
170 else
171 {
172 1 return( $self->_get_parent_form );
173 }
174 }
175  
176 # Note: property for input
177 0 ▶sub formAction : lvalue { return( shift->_set_get_form_attribute( 'action', @_ ) ); }
Subroutine formAction: not called CC=1 SCAR=6.9
Pod documented
178  
179 # Note: property for input
180 0 ▶sub formEnctype : lvalue { return( shift->_set_get_form_attribute( 'enctype', @_ ) ); }
Subroutine formEnctype: not called CC=1 SCAR=6.9
Pod documented
181  
182 # Note: property for input
183 0 ▶sub formMethod : lvalue { return( shift->_set_get_form_attribute( 'method', @_ ) ); }
Subroutine formMethod: not called CC=1 SCAR=6.9
Pod documented
184  
185 # Note: property for input
186 0 ▶sub formNoValidate : lvalue { return( shift->_set_get_form_attribute( 'novalidate', @_ ) ); }
Subroutine formNoValidate: not called CC=1 SCAR=6.9
Pod documented
187  
188 # Note: property for input
189 0 ▶sub formTarget : lvalue { return( shift->_set_get_form_attribute( 'target', @_ ) ); }
Subroutine formTarget: not called CC=1 SCAR=6.9
Pod documented
190  
191 # Note: property for anchor
192 4 ▶sub hash : lvalue { return( shift->_set_get_uri_property( 'hash', @_ ) ); }
Subroutine hash: called CC=1 SCAR=0.0
Pod documented
193  
194 # Note: property for input
195 0 ▶sub height : lvalue { return( shift->_set_get_property( 'height', @_ ) ); }
Subroutine height: not called CC=1 SCAR=6.9
Pod documented
196  
197 # Note: property for anchor
198 2 ▶sub host : lvalue { return( shift->_set_get_uri_property( 'host', @_ ) ); }
Subroutine host: called CC=1 SCAR=0.0
Pod documented
199  
200 # Note: property for anchor
201 3 ▶sub hostname : lvalue { return( shift->_set_get_uri_property( 'hostname', @_ ) ); }
Subroutine hostname: called CC=1 SCAR=0.0
Pod documented
202  
203 # Note: property for anchor
204 32 ▶sub href : lvalue { return( shift->_set_get_property( { attribute => 'href', is_uri => 1 }, @_ ) ); }
Subroutine href: called CC=1 SCAR=0.0
Pod documented
205  
206 # Note: property for anchor
207 2 ▶sub hreflang : lvalue { return( shift->_set_get_property( 'hreflang', @_ ) ); }
Subroutine hreflang: called CC=1 SCAR=0.0
Pod undocumented
208  
209 # Note: property boolean for input
210 0 ▶sub indeterminate : lvalue { return( shift->_set_get_property( { attribute => 'indeterminate', is_boolean => 1 }, @_ ) ); }
Subroutine indeterminate: not called CC=1 SCAR=6.9
Pod documented
211  
212 #Note: property for input
213 0 ▶sub inputmode : lvalue { return( shift->_set_get_property( 'inputmode', @_ ) ); }
Subroutine inputmode: not called CC=1 SCAR=6.9
Pod documented
214  
215 # Note: property
216 sub labels
217 {
218 0 ▶ my $self = shift( @_ );
Subroutine labels: not called CC=4 SCAR=30.0
Pod documented
219 0 my $results = $self->new_array;
220 # No need to go further really
221 0 my $id = $self->attributes->get( 'id' );
222 0 ▶ return( $results ) if( !defined( $id ) || !length( $id ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id and length $id 0 0 0
Condition0%0/3
defined $id and length $id
!ll&&!rl&&r
000
MC/DC0%0/2
defined $id and length $id
defined $id length $id
Truth table0%0/3
A and B
A= defined $idB= length $id
ABresult
0X0
100
111
223 0 ▶ my $root = $self->root || return( $results );
Condition0%0/2
$self->root || (return $results)
l!l
00
MC/DC0%0/1
$self->root || (return $results)
$self->root
Truth table0%0/2
A
A= $self->root
Aresult
11
00
224 0 $results = $root->look_down( _tag => 'label', 'for' => $id );
225 0 return( $self->new_nodelist( $results ) );
226 }
227  
228 # Note: property for input; an element object pointing to <datalist>
229 sub list
230 {
231 0 ▶ my $self = shift( @_ );
Subroutine list: not called CC=4 SCAR=30.0
Pod documented
232 0 ▶ if( @_ )
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
233 {
234 0 return( $self->_set_get_object_without_init( 'list', 'HTML::Object::DOM::Element', @_ ) );
235 }
236 else
237 {
238 0 ▶ return( $self->{list} ) if( ref( $self->{list} ) );
Branch: 1 branch
BranchTrueFalseTotal
if ref $self->{"list"} 0 0 0
239 0 my $root = $self->root;
240 0 my $id = $self->attr( 'list' );
241 0 ▶ return( $self->new_null ) if( !defined( $id ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 0 0 0
242 0 my $elem = $root->look_down( _tag => 'datalist', id => $id );
243 0 return( $self->{list} = $elem );
244 }
245 }
246  
247 # Note: property for input
248 0 ▶sub max : lvalue { return( shift->_set_get_property( 'max', @_ ) ); }
Subroutine max: not called CC=1 SCAR=6.9
Pod documented
249  
250 # Note: property for input
251 0 ▶sub maxLength : lvalue { return( shift->_set_get_property( 'maxlength', @_ ) ); }
Subroutine maxLength: not called CC=1 SCAR=6.9
Pod documented
252  
253 # Note: property for input
254 0 ▶sub min : lvalue { return( shift->_set_get_property( 'min', @_ ) ); }
Subroutine min: not called CC=1 SCAR=6.9
Pod documented
255  
256 # Note: property for input
257 0 ▶sub minLength : lvalue { return( shift->_set_get_property( 'minlength', @_ ) ); }
Subroutine minLength: not called CC=1 SCAR=6.9
Pod documented
258  
259 # Note: property boolean for input
260 0 ▶sub multiple : lvalue { return( shift->_set_get_property( { attribute => 'multiple', is_boolean => 1 }, @_ ) ); }
Subroutine multiple: not called CC=1 SCAR=6.9
Pod documented
261  
262 # Note: property for input
263 3 ▶sub name : lvalue { return( shift->_set_get_property( 'name', @_ ) ); }
Subroutine name: called CC=1 SCAR=0.0
Pod documented
264  
265 # Note: property for anchor
266 sub origin
267 {
268 3 ▶ my $self = shift( @_ );
Subroutine origin: called CC=4 SCAR=14.3
Pod undocumented
269 3 my $uri = $self->_set_get_anchor_uri;
270 # We use ref() and not ->isa on purpose, because URI::https (for example) is a subclass of URI::_generic
271 # so ->isa( 'URI::_generic' ) will always return true
272 3 ▶ return if( ref( $uri ) eq 'URI::_generic' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $uri eq "URI::_generic" 0 3 3
273 3 ▶ return if( !$uri->host );
Branch: 1 branch
BranchTrueFalseTotal
unless $uri->host 0 3 3
274 # The web standard is to return a hostname without its port if it is a standard port, even if it was specified
275 # e.g. https://example.org:443 -> https://example.org
276 # return( $uri->canonical );
277 # I need a way to remove the port if it is standard. URI->canonical gives us that, but also includes the path, which we do not want
278 # and we do not want a trailing '/', which canonical adds
279 3 my $origin = URI->new( join( '', $uri->scheme, '://', $uri->host_port ) )->canonical;
280 # substr( $origin, -1, 1, '' ) if( substr( $origin, -1, 1 ) eq '/' );
281 3 ▶ $origin->path( substr( $origin->path, 0, -1 ) ) if( substr( $origin->path, -1, 1 ) eq '/' );
Branch: 1 branch
BranchTrueFalseTotal
if substr($origin->path, -1, 1) eq "/" 3 0 3
282 3 return( $origin );
283 }
284  
285 # Note: property for anchor
286 2 ▶sub password : lvalue { return( shift->_set_get_uri_property( 'password', @_ ) ); }
Subroutine password: called CC=1 SCAR=0.0
Pod documented
287  
288 # Note: property for anchor
289 3 ▶sub pathname : lvalue { return( shift->_set_get_uri_property( 'pathname', @_ ) ); }
Subroutine pathname: called CC=1 SCAR=0.0
Pod documented
290  
291 # Note: property for input
292 0 ▶sub pattern : lvalue { return( shift->_set_get_property( 'pattern', @_ ) ); }
Subroutine pattern: not called CC=1 SCAR=6.9
Pod documented
293  
294 # Note: property for input
295 0 ▶sub placeholder : lvalue { return( shift->_set_get_property( 'placeholder', @_ ) ); }
Subroutine placeholder: not called CC=1 SCAR=6.9
Pod documented
296  
297 # Note: property for anchor
298 2 ▶sub port : lvalue { return( shift->_set_get_uri_property( 'port', @_ ) ); }
Subroutine port: called CC=1 SCAR=0.0
Pod undocumented
299  
300 # Note: property for anchor
301 4 ▶sub protocol : lvalue { return( shift->_set_get_uri_property( 'protocol', @_ ) ); }
Subroutine protocol: called CC=1 SCAR=0.0
Pod undocumented
302  
303 # Note: property boolean for input
304 0 ▶sub readOnly : lvalue { return( shift->_set_get_property( { attribute => 'readonly', is_boolean => 1 }, @_ ) ); }
Subroutine readOnly: not called CC=1 SCAR=6.9
Pod documented
305  
306 # Note: property for anchor
307 2 ▶sub referrerPolicy : lvalue { return( shift->_set_get_property( 'referrerpolicy', @_ ) ); }
Subroutine referrerPolicy: called CC=1 SCAR=0.0
Pod undocumented
308  
309 # Note: property for anchor
310 3 ▶sub rel : lvalue { return( shift->_set_get_property( 'rel', @_ ) ); }
Subroutine rel: called CC=1 SCAR=0.0
Pod documented
311  
312 # Note: property for anchor
313 sub relList
314 {
315 3 ▶ my $self = shift( @_ );
Subroutine relList: called CC=3 SCAR=11.0
Pod undocumented
316 3 ▶ unless( $self->{_rel_list} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_rel_list"}) 1 2 3
317 {
318 1 my $rel = $self->attr( 'rel' );
319 1 require HTML::Object::TokenList;
320 1 ▶ $self->{_rel_list} = HTML::Object::TokenList->new( $rel, element => $self, attribute => 'rel', debug => $self->debug ) ||
Condition50%1/2
'HTML::Object::TokenList'->new($rel, 'element', $self, 'attribute', 'rel', 'debug', $self->debug) || (return $self->pass_error('HTML::Object::TokenList'->error))
l!l
10
MC/DC0%0/1
'HTML::Object::TokenList'->new($rel, 'element', $self, 'attribute', 'rel', 'debug', $self->debug) || (return $self->pass_error('HTML::Object::TokenList'->error))
'HTML::Object::TokenList'->new($rel, 'element', $self, 'attribute', 'rel', 'debug', $self->debug)
Truth table50%1/2
A
A= 'HTML::Object::TokenList'->new($rel, 'element', $self, 'attribute', 'rel', 'debug', $self->debug)
Aresult
11
00
321 return( $self->pass_error( HTML::Object::TokenList->error ) );
322 }
323 3 return( $self->{_rel_list} );
324 }
325  
326 # Note: method
327 0 ▶sub reportValidity { return( shift->_set_get_boolean( 'reportValidity', @_ ) ); }
Subroutine reportValidity: not called CC=1 SCAR=6.9
Pod documented
328  
329 # Note: property for input
330 0 ▶sub required : lvalue { return( shift->_set_get_property( { attribute => 'required', is_boolean => 1 }, @_ ) ); }
Subroutine required: not called CC=1 SCAR=6.9
Pod documented
331  
332 # Note: property for input
333 0 ▶sub selectionDirection : lvalue { return( shift->_set_get_property( 'selectiondirection', @_ ) ); }
Subroutine selectionDirection: not called CC=1 SCAR=6.9
Pod documented
334  
335 # Note: property for input
336 0 ▶sub selectionEnd : lvalue { return( shift->_set_get_property( 'selectionend', @_ ) ); }
Subroutine selectionEnd: not called CC=1 SCAR=6.9
Pod documented
337  
338 # Note: property for input
339 0 ▶sub selectionStart : lvalue { return( shift->_set_get_property( 'selectionstart', @_ ) ); }
Subroutine selectionStart: not called CC=1 SCAR=6.9
Pod documented
340  
341 # Note: property for anchor
342 2 ▶sub search : lvalue { return( shift->_set_get_uri_property( 'search', @_ ) ); }
Subroutine search: called CC=1 SCAR=0.0
Pod documented
343  
344 # Note: method for fieldset, input, object
345 0 ▶sub setCustomValidity { return( shift->_set_get_scalar_as_object( 'setcustomvalidity', @_ ) ); }
Subroutine setCustomValidity: not called CC=1 SCAR=6.9
Pod undocumented
346  
347 0 ▶sub size : lvalue { return( shift->_set_get_property( 'selectionstart', @_ ) ); }
Subroutine size: not called CC=1 SCAR=6.9
Pod documented
348  
349 # Note: property for input
350 0 ▶sub src : lvalue { return( shift->_set_get_property( { attribute => 'src', is_uri => 1 }, @_ ) ); }
Subroutine src: not called CC=1 SCAR=6.9
Pod documented
351  
352 # Note: property for input
353 0 ▶sub step : lvalue { return( shift->_set_get_property( 'step', @_ ) ); }
Subroutine step: not called CC=1 SCAR=6.9
Pod documented
354  
355 # Note: tabIndex is inherited directly HTML::Object::DOM::Element
356  
357 # Note: property for anchor
358 2 ▶sub target : lvalue { return( shift->_set_get_property( 'target', @_ ) ); }
Subroutine target: called CC=1 SCAR=0.0
Pod undocumented
359  
360 # Note: property for input
361 1 ▶sub type : lvalue { return( shift->_set_get_property( 'type', @_ ) ); }
Subroutine type: called CC=1 SCAR=0.0
Pod documented
362  
363 # Note: property for img, input
364 0 ▶sub useMap : lvalue { return( shift->_set_get_property( 'usemap', @_ ) ); }
Subroutine useMap: not called CC=1 SCAR=6.9
Pod undocumented
365  
366 # Note: property for anchor
367 2 ▶sub username : lvalue { return( shift->_set_get_uri_property( 'username', @_ ) ); }
Subroutine username: called CC=1 SCAR=0.0
Pod undocumented
368  
369 # Note: property for input
370 111 ▶sub value : lvalue { return( shift->_set_get_property( 'value', @_ ) ); }
Subroutine value: called CC=1 SCAR=0.0
Pod documented
371  
372 # Note: property read-only for input
373 0 ▶sub validationMessage : lvalue { return( shift->_set_get_scalar_as_object( 'validationmessage', @_ ) ); }
Subroutine validationMessage: not called CC=1 SCAR=6.9
Pod documented
374  
375 # Note: property read-only for input
376 0 ▶sub validity { return( shift->_set_get_object( 'validity', 'HTML::Object::DOM::ValidityState', @_ ) ); }
Subroutine validity: not called CC=1 SCAR=6.9
Pod documented
377  
378 # Note: property for input
379 0 ▶sub valueAsDate : lvalue { return( shift->_set_get_property( { attribute => 'value', is_datetime => 1 }, @_ ) ); }
Subroutine valueAsDate: not called CC=1 SCAR=6.9
Pod documented
380  
381 # Note: property for input
382 0 ▶sub valueAsNumber : lvalue { return( shift->_set_get_property( { attribute => 'value', is_number => 1 }, @_ ) ); }
Subroutine valueAsNumber: not called CC=1 SCAR=6.9
Pod documented
383  
384 # Note: property boolean for input
385 0 ▶sub webkitdirectory : lvalue { return( shift->_set_get_property( { attribute => 'webkitdirectory', is_boolean => 1 }, @_ ) ); }
Subroutine webkitdirectory: not called CC=1 SCAR=6.9
Pod documented
386  
387 0 ▶sub webkitEntries { return; }
Subroutine webkitEntries: not called CC=1 SCAR=6.9
Pod documented
388  
389 # Note: property read-only for input
390 0 ▶sub willValidate : lvalue { return( shift->_set_get_boolean( 'willvalidate', @_ ) ); }
Subroutine willValidate: not called CC=1 SCAR=6.9
Pod documented
391  
392 # Note: property for input
393 0 ▶sub width : lvalue { return( shift->_set_get_property( 'width', @_ ) ); }
Subroutine width: not called CC=1 SCAR=6.9
Pod documented
394  
395 25 1;
396 # NOTE: POD
397 __END__
398  
399 =encoding utf-8
400  
401 =head1 NAME
402  
403 HTML::Object::DOM::Element::Shared - HTML Object DOM Form Shared Code
404  
405 =head1 SYNOPSIS
406  
407 use HTML::Object::DOM::Element::Shared qw( :input );
408  
409 =head1 VERSION
410  
411 v0.2.0
412  
413 =head1 DESCRIPTION
414  
415 This module implements properties and methods shared among several form elements
416  
417 =head1 PROPERTIES
418  
419 =head2 accept
420  
421 Set or return the element's accept attribute, containing comma-separated list of file types accepted by the server when type is file.
422  
423 =head2 accessKey
424  
425 Sets or gets the element's attribute representing a string containing a single character that switches input focus to the control when pressed.
426  
427 =for Pod::Coverage align
428  
429 =head2 allowdirs
430  
431 Set or get a boolean value. This does not do anything otherwise since this is not an attribute.
432  
433 This is part of Mozilla non-standard Directory Upload API. It indicates whether or not to allow directories and files both to be selected in the file list.
434  
435 =head2 alt
436  
437 Sets or returns the element's alt attribute, containing alternative text to use when type is image.
438  
439 =head2 autocapitalize
440  
441 Defines the capitalization behavior for user input. Valid values are C<none>, C<off>, C<characters>, C<words>, or C<sentences>.
442  
443 =head2 autocomplete
444  
445 Set or returns a string that represents the element's autocomplete attribute, indicating whether the value of the control can be automatically completed by the browser. Ignored if the value of the type attribute is C<hidden>, C<checkbox>, C<radio>, C<file>, or a C<button> type (C<button>, C<submit>, C<reset>, C<image>). Possible values are:
446  
447 =over 4
448  
449 =item on
450  
451 The browser can autocomplete the value using previously stored value
452  
453 =item off
454  
455 The user must explicity enter a value
456  
457 =back
458  
459 =head2 autofocus
460  
461 Set or returns a boolean value that represents the element's autofocus attribute, which specifies that a form control should have input focus when the page loads, unless the user overrides it, for example by typing in a different control. Only one form element in a document can have the autofocus attribute. It cannot be applied if the type attribute is set to hidden (that is, you cannot automatically set focus to a hidden control).
462  
463 =head2 checked
464  
465 Set or returns a boolean value the current state of the element when type is checkbox or radio.
466  
467 =for Pod::Coverage compact
468  
469 =head2 crossOrigin
470  
471 A string of a keyword specifying the CORS mode to use when fetching the image resource. If you do not specify crossOrigin, the underlying element is fetched without CORS (the fetch no-cors mode).
472  
473 Permitted values are:
474  
475 =over 4
476  
477 =item * C<anonymous>
478  
479 Requests by the underlying element have their mode set to cors and their credentials mode set to same-origin. This means that CORS is enabled and credentials are sent if the underlying element is fetched from the same origin from which the document was loaded.
480  
481 =item * C<use-credentials>
482  
483 Requests by the L<HTML::Object::DOM::Element> will use the cors mode and the include credentials mode; all underlying element requests by the element will use CORS, regardless of what domain the fetch is from.
484  
485 =back
486  
487 If crossOrigin is an empty string (""), the anonymous mode is selected.
488  
489 See L<Mozilla documentation for more information|https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin>
490  
491 =for Pod::Coverage currentSrc
492  
493 =head2 defaultChecked
494  
495 Set or returns a boolean value that sets the default state of a radio button or checkbox as originally specified in HTML that created this object.
496  
497 =for Pod::Coverage defaultValue
498  
499 =head2 dirName
500  
501 Sets or gets the directionality of the element.
502  
503 =head2 disabled
504  
505 Set or returns a boolean value that represents the element's disabled attribute, indicating that the control is not available for interaction. The input values will not be submitted with the form. See also L</readonly>
506  
507 =for Pod::Coverage download
508  
509 =head2 files
510  
511 This returns a L<HTML::Object::DOM::FileList> object.
512  
513 Under JavaScript, this returns or accepts a C<FileList> object, which contains a list of C<File> objects representing the files selected for upload.
514  
515 =head2 form
516  
517 The C<form> HTML element represents a document section containing interactive controls for submitting information.
518  
519 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form>
520  
521 =head2 formAction
522  
523 Is a string reflecting the L<URI> of a resource that processes information submitted by the button. If specified, this property overrides the action attribute of the C<<form>> element that owns this element.
524  
525 This is used by L<HTML::Object::DOM::Element::Input>
526  
527 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/formAction>
528  
529 =head2 formEnctype
530  
531 Is a string reflecting the type of content that is used to submit the form to the server. If specified, this property overrides the enctype attribute of the C<<form>> element that owns this element.
532  
533 This is used by L<HTML::Object::DOM::Element::Input>
534  
535 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/formEnctype>
536  
537 =head2 formMethod
538  
539 Is a string reflecting the HTTP method that the browser uses to submit the form. If specified, this property overrides the method attribute of the <form> element that owns this element.
540  
541 This is used by L<HTML::Object::DOM::Element::Input>
542  
543 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/formMethod>
544  
545 =head2 formNoValidate
546  
547 Is a boolean value indicating that the form is not to be validated when it is submitted. If specified, this property overrides the novalidate attribute of the <form> element that owns this element.
548  
549 This is used by L<HTML::Object::DOM::Element::Input>
550  
551 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/formNoValidate>
552  
553 =head2 formTarget
554  
555 Is a string reflecting a name or keyword indicating where to display the response that is received after submitting the form. If specified, this property overrides the target attribute of the <form> element that owns this element.
556  
557 This is used by L<HTML::Object::DOM::Element::Input>
558  
559 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/formTarget>
560  
561 =head2 hash
562  
563 The hash property of the Location interface returns a string containing a '#' followed by the fragment identifier of the URL - the ID on the page that the URL is trying to target.
564  
565 The fragment is not percent-decoded. If the URL does not have a fragment identifier, this property contains an empty string, "".
566  
567 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Location/hash>
568  
569 =head2 height
570  
571 Sets or returns the element's height attribute, which defines the height of the image displayed for the button, if the value of type is image.
572  
573 =head2 host
574  
575 The host property of the Location interface is a string containing the host, that is the hostname, and then, if the port of the URL is nonempty, a ':', and the port of the URL.
576  
577 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Location/host>
578  
579 =head2 hostname
580  
581 The hostname property of the Location interface is a string containing the domain of the URL.
582  
583 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Location/hostname>
584  
585 =head2 href
586  
587 The href property of the Location interface is a stringifier that returns a string containing the whole URL, and allows the href to be updated.
588  
589 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Location/href>
590  
591 =for Pod::Coverage hreflang
592  
593 =head2 indeterminate
594  
595 Set or returns a boolean value that describes whether the checkbox or radio button is in indeterminate state. For checkboxes, the effect is that the appearance of the checkbox is obscured/greyed in some way as to indicate its state is indeterminate (not checked but not unchecked). Does not affect the value of the checked attribute, and clicking the checkbox will set the value to false.
596  
597 =head2 inputmode
598  
599 Provides a hint to browsers as to the type of virtual keyboard configuration to use when editing this element or its contents.
600  
601 =head2 labels
602  
603 Returns a list of C<<label>> elements that are labels for this element, as an L<array object|Module::Generic::Array>.
604  
605 =head2 list
606  
607 Sets or returns the L<element|HTML::Object::DOM::Element> pointed by the C<list> attribute, which returns an ID. The property may be C<undef> if no HTML element found in the same tree.
608  
609 =head2 max
610  
611 Set or returns a string that represents the element's C<max> attribute, containing the maximum (numeric or date-time) value for this item, which must not be less than its minimum (min attribute) value.
612  
613 =head2 maxLength
614  
615 Set or returns an integer that represents the element's C<maxlength> attribute, containing the maximum number of characters (in Unicode code points) that the value can have. (If you set this to a negative number, an exception will be thrown.)
616  
617 =head2 min
618  
619 Set or returns a string that represents the element's C<min> attribute, containing the minimum (numeric or date-time) value for this item, which must not be greater than its maximum (max attribute) value.
620  
621 =head2 minLength
622  
623 Set or returns an integer that represents the element's C<minlength> attribute, containing the minimum number of characters (in Unicode code points) that the value can have. (If you set this to a negative number, an exception will be thrown.)
624  
625 =head2 multiple
626  
627 Sets or returns a boolean that represents the element's multiple attribute, indicating whether more than one value is possible (e.g., multiple files).
628  
629 =head2 name
630  
631 Set or returns the element's name attribute, containing a name that identifies the element when submitting the form.
632  
633 =for Pod::Coverage origin
634  
635 =head2 password
636  
637 The password property of the Location interface is a string containing the password specified before the domain name.
638  
639 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Location/password>
640  
641 =head2 pathname
642  
643 The pathname property of the Location interface is a USVString containing the path of the URL for the location, which will be the empty string if there is no path.
644  
645 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Location/pathname>
646  
647 =head2 pattern
648  
649 Set or returns a string that represents the element's C<pattern> attribute, containing a regular expression that the control's value is checked against. Use the C<title> attribute to describe the pattern to help the user. This attribute applies when the value of the type attribute is C<text>, C<search>, C<tel>, C<url> or C<email>; otherwise it is ignored.
650  
651 =head2 placeholder
652  
653 Set or returns a string that represents the element's C<placeholder> attribute, containing a hint to the user of what can be entered in the control. The C<placeholder> text must not contain carriage returns or line-feeds. This attribute applies when the value of the type attribute is C<text>, C<search>, C<tel>, C<url> or C<email>; otherwise it is ignored.
654  
655 =for Pod::Coverage port
656  
657 =for Pod::Coverage protocol
658  
659 =head2 readOnly
660  
661 Set or returns a boolean that represents the element's C<readonly> attribute, indicating that the user cannot modify the value of the control.
662 This is ignored if the value of the type attribute is C<hidden>, C<range>, C<color>, C<checkbox>, C<radio>, C<file>, or a C<button> type.
663  
664 =for Pod::Coverage referrerPolicy
665  
666 =head2 rel
667  
668 The rel attribute defines the relationship between a linked resource and the current document.
669  
670 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel>
671  
672 =for Pod::Coverage relList
673  
674 =head2 required
675  
676 Set or returns a boolean value that represents the element's required attribute, indicating that the user must fill in a value before submitting a form.
677  
678 =head2 search
679  
680 The search property of the Location interface is a search string, also called a query string; that is, a USVString containing a '?' followed by the parameters of the URL.
681  
682 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Location/search>
683  
684 =head2 selectionDirection
685  
686 Set or returns a string that represents the direction in which selection occurred. Possible values are:
687  
688 =over 4
689  
690 =item forward
691  
692 if selection was performed in the start-to-end direction of the current locale
693  
694 =item backward
695  
696 for the opposite direction
697  
698 =item none
699  
700 if the direction is unknown
701  
702 =back
703  
704 =head2 selectionEnd
705  
706 Set or returns an integer that represents the end index of the selected text. When there's no selection, this returns the offset of the character immediately following the current text input cursor position.
707  
708 =head2 selectionStart
709  
710 Set or returns an integer that represents the beginning index of the selected text. When nothing is selected, this returns the position of the text input cursor (caret) inside of the <input> element.
711  
712 =for Pod::Coverage setCustomValidity
713  
714 =head2 size
715  
716 Set or returns an integer that represents the element's C<size> attribute, containing visual size of the control. This value is in pixels unless the value of type is text or password, in which case, it is an integer number of characters. Applies only when type is set to C<text>, C<search>, C<tel>, C<url>, C<email>, or C<password>; otherwise it is ignored.
717  
718 =head2 step
719  
720 Set or returns the element's step attribute, which works with C<min> and C<max> to limit the increments at which a numeric or date-time value can be set. It can be the string any or a positive floating point number. If this is not set to C<any>, the control accepts only values at multiples of the step value greater than the minimum.
721  
722 =head2 src
723  
724 Sets or returns the element's src attribute, which specifies a URI for the location of an image to display on the graphical submit button, if the value of type is image; otherwise it is ignored.
725  
726 =for Pod::Coverage target
727  
728 =head2 type
729  
730 Set or returns the element's type attribute, indicating the type of control to display. See type attribute of C<<input>> for possible values.
731  
732 =for Pod::Coverage useMap
733  
734 =for Pod::Coverage username
735  
736 =head2 value
737  
738 Set or returns the current value of the control.
739  
740 =head2 valueAsDate
741  
742 Sets or returns the value of the element, interpreted as a L<DateTime> object, or C<undef> if conversion is not possible.
743  
744 =head2 valueAsNumber
745  
746 Returns the value of the L<element|HTML::Object::DOM::Element>, interpreted as one of the following, in order:
747  
748 =over 4
749  
750 =item * A time value
751  
752 =item * A number
753  
754 =item * C<undef> if conversion is impossible
755  
756 =back
757  
758 =head2 validity
759  
760 Read-only.
761  
762 L<ValidityState object|HTML::Object::DOM::ValidityState>: Returns the element's current validity state.
763  
764 =head2 validationMessage
765  
766 Read-only.
767  
768 Set or returns a localised message that describes the validation constraints that the control does not satisfy (if any). This is the empty string if the control is not a candidate for constraint validation (willvalidate is false), or it satisfies its constraints. This value can be set by the setCustomValidity method.
769  
770 =head2 webkitdirectory
771  
772 A boolean value: Returns the webkitdirectory attribute; if true, the file system picker interface only accepts directories instead of files.
773  
774 See L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory>
775  
776 =head2 webkitEntries
777  
778 This does nothing under perl, and returns C<undef>
779  
780 See L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitEntries>
781  
782 =head2 width
783  
784 Sets or returns the element's width attribute, which defines the width of the image displayed for the button, if the value of type is image.
785  
786 =head2 willValidate
787  
788 Read-only.
789  
790 Set or returns a boolean value that describes whether the element is a candidate for constraint validation. It is false if any conditions bar it from constraint validation, including: its type is hidden, reset, or button; it has a <datalist> ancestor; its disabled property is true.
791  
792 =head1 METHODS
793  
794 =head2 checkValidity
795  
796 In perl, this always returns true, or whatever value you would have set.
797  
798 In JavaScript environment, this returns true if the element's child controls are subject to constraint validation and satisfy those constraints; returns false if some controls do not satisfy their constraints. Fires an event named invalid at any control that does not satisfy its constraints; such controls are considered invalid if the event is not canceled. It is up to the programmer to decide how to respond to false.
799  
800 See also L<Mozilla documentation on form|https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/checkValidity>, L<Mozilla doc on input|https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity>
801  
802 =head2 reportValidity
803  
804 In perl, this always returns true, or whatever value you would have set.
805  
806 In JavaScript environment, this returns true if the element's child controls satisfy their validation constraints. When false is returned, cancelable invalid events are fired for each invalid child and validation problems are reported to the user.
807  
808 Example:
809  
810 $doc->forms->myform->addEventListener( submit => sub
811 {
812 $doc->forms->myform->reportValidity();
813 }, { capture => 0 });
814  
815 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reportValidity>, L<Mozilla doc on input|https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reportValidity>
816  
817 =head1 AUTHOR
818  
819 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
820  
821 =head1 SEE ALSO
822  
823 L<HTML::Object::DOM::Element>, L<HTML::Object::DOM::Element::Anchor> L<HTML::Object::DOM::Element::Area> L<HTML::Object::DOM::Element::Audio> L<HTML::Object::DOM::Element::Base> L<HTML::Object::DOM::Element::Body> L<HTML::Object::DOM::Element::BR> L<HTML::Object::DOM::Element::Button> L<HTML::Object::DOM::Element::Canvas> L<HTML::Object::DOM::Element::DataList> L<HTML::Object::DOM::Element::Data> L<HTML::Object::DOM::Element::Details> L<HTML::Object::DOM::Element::Dialog> L<HTML::Object::DOM::Element::Directory> L<HTML::Object::DOM::Element::Div> L<HTML::Object::DOM::Element::DList> L<HTML::Object::DOM::Element::Embed> L<HTML::Object::DOM::Element::FieldSet> L<HTML::Object::DOM::Element::Form> L<HTML::Object::DOM::Element::Heading> L<HTML::Object::DOM::Element::Head> L<HTML::Object::DOM::Element::HR> L<HTML::Object::DOM::Element::HTML> L<HTML::Object::DOM::Element::IFrame> L<HTML::Object::DOM::Element::Image> L<HTML::Object::DOM::Element::Input> L<HTML::Object::DOM::Element::Label> L<HTML::Object::DOM::Element::Legend> L<HTML::Object::DOM::Element::Link> L<HTML::Object::DOM::Element::LI> L<HTML::Object::DOM::Element::Map> L<HTML::Object::DOM::Element::Marquee> L<HTML::Object::DOM::Element::Media> L<HTML::Object::DOM::Element::Menu> L<HTML::Object::DOM::Element::Meta> L<HTML::Object::DOM::Element::Meter> L<HTML::Object::DOM::Element::Mod> L<HTML::Object::DOM::Element::Object> L<HTML::Object::DOM::Element::OList> L<HTML::Object::DOM::Element::OptGroup> L<HTML::Object::DOM::Element::Option> L<HTML::Object::DOM::Element::Output> L<HTML::Object::DOM::Element::Paragraph> L<HTML::Object::DOM::Element::Param> L<HTML::Object::DOM::Element::Picture> L<HTML::Object::DOM::Element::Pre> L<HTML::Object::DOM::Element::Progress> L<HTML::Object::DOM::Element::Quote> L<HTML::Object::DOM::Element::Script> L<HTML::Object::DOM::Element::Select> L<HTML::Object::DOM::Element::Slot> L<HTML::Object::DOM::Element::Source> L<HTML::Object::DOM::Element::Span> L<HTML::Object::DOM::Element::Style> L<HTML::Object::DOM::Element::TableCaption> L<HTML::Object::DOM::Element::TableCell> L<HTML::Object::DOM::Element::TableCol> L<HTML::Object::DOM::Element::Table> L<HTML::Object::DOM::Element::TableRow> L<HTML::Object::DOM::Element::TableSection> L<HTML::Object::DOM::Element::Template> L<HTML::Object::DOM::Element::TextArea> L<HTML::Object::DOM::Element::Time> L<HTML::Object::DOM::Element::Title> L<HTML::Object::DOM::Element::Track> L<HTML::Object::DOM::Element::UList> L<HTML::Object::DOM::Element::Unknown> L<HTML::Object::DOM::Element::Video>
824  
825 =head1 COPYRIGHT & LICENSE
826  
827 Copyright(c) 2021 DEGUEST Pte. Ltd.
828  
829 All rights reserved
830  
831 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
832  
833 =cut
« blib/lib/HTML/Object/DOM/Space.pm ↑ Summary lib/HTML/Object/DOM/Element/FieldSet.pm »