blib/lib/HTML/Object/DOM/Element/Button.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 47 CC 2 SCAR 10.0
CC
2
Cov
0%
init
6.0
BEGIN
2.0
menu
2.0
CRAP 2.7
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/DOM/Element/Button.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/12/23
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::Button;
15 BEGIN
16 {
17 use strict;
18 use warnings;
19 warnings::register_categories( 'HTML::Object' );
20 use parent qw( HTML::Object::DOM::Element );
21 use vars qw( $VERSION );
22 use HTML::Object::DOM::Element::Shared qw( :button );
23 our $VERSION = 'v0.2.0';
24 };
25  
26 use strict;
27 use warnings;
28  
29 sub init
30 {
31 my $self = shift( @_ );
32 $self->{_init_strict_use_sub} = 1;
33 $self->SUPER::init( @_ ) || return( $self->pass_error );
34 $self->{tag} = 'button' if( !CORE::length( "$self->{tag}" ) );
35 return( $self );
36 }
37  
38 # Note: property accessKey inherited
39  
40 # Note: property autofocus inherited
41  
42 # Note: property disabled inherited
43  
44 # Note: property read-only form inherited
45  
46 # Imported from FormShared
47 # # Note: property
48 # sub formAction : lvalue { return( shift->_set_get_form_attribute( 'action', @_ ) ); }
49 #
50 # # Note: property
51 # sub formEnctype : lvalue { return( shift->_set_get_form_attribute( 'enctype', @_ ) ); }
52 #
53 # # Note: property
54 # sub formMethod : lvalue { return( shift->_set_get_form_attribute( 'method', @_ ) ); }
55 #
56 # # Note: property
57 # sub formNoValidate : lvalue { return( shift->_set_get_form_attribute( 'novalidate', @_ ) ); }
58 #
59 # # Note: property
60 # sub formTarget : lvalue { return( shift->_set_get_form_attribute( 'target', @_ ) ); }
61  
62 # Note: property labels inherited
63  
64 # Note: property, but NOT an lvalue method
65 sub menu { return( shift->_set_get_object( 'menu', 'HTML::Object::DOM::Element::Menu', @_ ) ); }
66  
67 # Note: property name inherited
68  
69 # Note: property tabIndex from HTML::Object::DOM::Element
70  
71 # Note: property type inherited
72  
73 # Note: property validationMessage inherited
74  
75 # Note: property validity inherited
76  
77 # Note: property value inherited
78  
79 # Note: property willValidate inherited
80  
81 1;
82 # NOTE: POD
83 __END__
84  
85 =encoding utf-8
86  
87 =head1 NAME
88  
89 HTML::Object::DOM::Element::Button - HTML Object DOM Button Class
90  
91 =head1 SYNOPSIS
92  
93 use HTML::Object::DOM::Element::Button;
94 my $button = HTML::Object::DOM::Element::Button->new ||
95 die( HTML::Object::DOM::Element::Button->error, "\n" );
96  
97 =head1 VERSION
98  
99 v0.2.0
100  
101 =head1 DESCRIPTION
102  
103 This interface provides properties and methods (beyond the regular L<HTML::Object::Element> interface it also has available to it by inheritance) for manipulating <button> elements.
104  
105 =head1 INHERITANCE
106  
107 +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +------------------------------------+
108 | HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Button |
109 +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +------------------------------------+
110  
111 =head1 PROPERTIES
112  
113 Inherits properties from its parent L<HTML::Object::DOM::Element>
114  
115 =head2 accessKey
116  
117 Is a string indicating the single-character keyboard key to give access to the button.
118  
119 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/accessKey>
120  
121 =head2 autofocus
122  
123 Is a boolean value indicating whether or not the 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-associated element in a document can have this attribute specified.
124  
125 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/autofocus>
126  
127 =head2 disabled
128  
129 Is a boolean value indicating whether or not the control is disabled, meaning that it does not accept any clicks.
130  
131 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/disabled>
132  
133 =head2 form
134  
135 Read-only.
136  
137 Is a L<HTML::Object::DOM::Element::Form> reflecting the form that this button is associated with. If the button is a descendant of a form element, then this property is the L<object|HTML::Object::DOM::Element::Form> of that form element.
138 If the button is not a descendant of a L<form element|HTML::Object::DOM::Element::Form>, then the property can be the object of any form element in the same document it is related to, or the C<undef> value if none matches.
139  
140 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/form>
141  
142 =head2 formAction
143  
144 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 <form> element that owns this element.
145  
146 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/formAction>
147  
148 =head2 formEnctype
149  
150 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 <form> element that owns this element.
151  
152 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/formEnctype>
153  
154 =head2 formMethod
155  
156 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.
157  
158 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/formMethod>
159  
160 =head2 formNoValidate
161  
162 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.
163  
164 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/formNoValidate>
165  
166 =head2 formTarget
167  
168 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.
169  
170 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/formTarget>
171  
172 =head2 labels
173  
174 Read-only.
175  
176 Is a NodeList that represents a list of <label> elements that are labels for this button.
177  
178 Example:
179  
180 <label id="label1" for="test">Label 1</label>
181 <button id="test">Button</button>
182 <label id="label2" for="test">Label 2</label>
183  
184 $doc->addEventListener( load => sub
185 {
186 my $button = $doc->getElementById("test");
187 for( my $i = 0; $i < $button->labels->length; $i++ )
188 {
189 say( $button->labels->[$i]->textContent ); # "Label 1" and "Label 2"
190 }
191 });
192  
193 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/labels>
194  
195 =head2 menu
196  
197 Is a L<HTML::Object::DOM::Element::Menu> representing the menu element to be displayed if the button is clicked and is of type="menu".
198  
199 Be careful that you cannot use this as an lvalue method. So you can only write:
200  
201 $button->menu( $menu_object );
202  
203 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/menu>
204  
205 =head2 name
206  
207 Is a string representing the name of the object when submitted with a form. If specified, it must not be the empty string.
208  
209 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/name>
210  
211 =head2 tabIndex
212  
213 Is a long that represents this element's position in the tabbing order.
214  
215 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/tabIndex>
216  
217 =head2 type
218  
219 Is a string indicating the behavior of the button. This is an enumerated attribute with the following possible values:
220  
221 =over 4
222  
223 =item submit
224  
225 The button submits the form. This is the default value if the attribute is not specified, or if it is dynamically changed to an empty or invalid value.
226  
227 =item reset
228  
229 The button resets the form.
230  
231 =item button
232  
233 The button does nothing.
234  
235 =item menu
236  
237 The button displays a menu.
238  
239 =back
240  
241 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/type>
242  
243 =head2 validationMessage
244  
245 Read-only.
246  
247 Is a string representing the localized message that describes the validation constraints that the control does not satisfy (if any). This attribute is the empty string if the control is not a candidate for constraint validation (willValidate is false), or it satisfies its constraints.
248  
249 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/validationMessage>
250  
251 =head2 validity
252  
253 Read-only.
254  
255 Is a L<ValidityState|HTML::Object::DOM::ValidityState> object representing the validity states that this button is in.
256  
257 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/validity>
258  
259 =head2 value
260  
261 Is a string representing the current form control value of the button.
262  
263 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/value>
264  
265 =head2 willValidate
266  
267 Read-only.
268  
269 Is a boolean value indicating whether the button is a candidate for constraint validation. It is false if any conditions bar it from constraint validation, including: its type property is reset or button; it has a <datalist> ancestor; or the disabled property is set to true.
270  
271 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/willValidate>
272  
273 =head1 METHODS
274  
275 Inherits methods from its parent L<HTML::Object::DOM::Element>
276  
277 =head1 AUTHOR
278  
279 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
280  
281 =head1 SEE ALSO
282  
283 L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement>, Mozilla documentation on button element|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button>
284  
285 =head1 COPYRIGHT & LICENSE
286  
287 Copyright(c) 2021 DEGUEST Pte. Ltd.
288  
289 All rights reserved
290  
291 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
292  
293 =cut