File Coverage

lib/HTML/Object/DOM/Element/Button.pm
Criterion Covered Total %
statement 27 28 96.4
branch 2 4 50.0
condition n/a
subroutine 9 10 90.0
pod 2 2 100.0
total 40 44 90.9


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