line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
## HTML Object - ~/lib/HTML/Object/DOM/Element/Output.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::Output; |
15
|
|
|
|
|
|
|
BEGIN |
16
|
|
|
|
|
|
|
{ |
17
|
3
|
|
|
3
|
|
2971
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
110
|
|
18
|
3
|
|
|
3
|
|
19
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
122
|
|
19
|
3
|
|
|
3
|
|
19
|
use parent qw( HTML::Object::DOM::Element ); |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
35
|
|
20
|
3
|
|
|
3
|
|
291
|
use vars qw( $VERSION ); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
169
|
|
21
|
3
|
|
|
3
|
|
25
|
use HTML::Object::DOM::Element::Shared qw( :output ); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
631
|
|
22
|
3
|
|
|
3
|
|
84
|
our $VERSION = 'v0.2.0'; |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
3
|
|
21
|
use strict; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
80
|
|
26
|
3
|
|
|
3
|
|
20
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
1254
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub init |
29
|
|
|
|
|
|
|
{ |
30
|
2
|
|
|
2
|
1
|
174
|
my $self = shift( @_ ); |
31
|
2
|
|
|
|
|
302
|
$self->{defaultvalue} = undef; |
32
|
2
|
|
|
|
|
7
|
$self->{_init_strict_use_sub} = 1; |
33
|
2
|
50
|
|
|
|
33
|
$self->SUPER::init( @_ ) || return( $self->pass_error ); |
34
|
2
|
50
|
|
|
|
10
|
$self->{tag} = 'output' if( !CORE::length( "$self->{tag}" ) ); |
35
|
2
|
|
|
|
|
21
|
$self->{type} = 'output'; |
36
|
|
|
|
|
|
|
$self->_set_get_internal_attribute_callback( 'for' => sub |
37
|
|
|
|
|
|
|
{ |
38
|
0
|
|
|
0
|
|
0
|
my( $this, $val ) = @_; |
39
|
0
|
|
|
|
|
0
|
my $list; |
40
|
0
|
0
|
|
|
|
0
|
return if( !( $list = $this->{_for_list} ) ); |
41
|
|
|
|
|
|
|
# $list->debug( $self->debug ); |
42
|
0
|
|
|
|
|
0
|
$list->update( $val ); |
43
|
2
|
|
|
|
|
30
|
}); |
44
|
2
|
|
|
|
|
7
|
return( $self ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Note: method checkValidity inherited |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Note: property defaultValue |
50
|
0
|
|
|
0
|
1
|
0
|
sub defaultValue : lvalue { return( shift->_set_get_property( 'defaultvalue', @_ ) ); } |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Note: property form read-only inherited |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Note: property htmlFor read-only |
55
|
|
|
|
|
|
|
sub htmlFor |
56
|
|
|
|
|
|
|
{ |
57
|
0
|
|
|
0
|
1
|
0
|
my $self = shift( @_ ); |
58
|
0
|
0
|
|
|
|
0
|
unless( $self->{_for_list} ) |
59
|
|
|
|
|
|
|
{ |
60
|
0
|
|
|
|
|
0
|
my $for = $self->attr( 'for' ); |
61
|
0
|
|
|
|
|
0
|
require HTML::Object::TokenList; |
62
|
0
|
|
0
|
|
|
0
|
$self->{_for_list} = HTML::Object::TokenList->new( $for, element => $self, attribute => 'for', debug => $self->debug ) || |
63
|
|
|
|
|
|
|
return( $self->pass_error( HTML::Object::TokenList->error ) ); |
64
|
|
|
|
|
|
|
} |
65
|
0
|
|
|
|
|
0
|
return( $self->{_for_list} ); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Note: property labels read-only inherited |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Note: property name inherited |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# Note: method reportValidity inherited |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Note: method setCustomValidity inherited |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Note: property type read-only inherited |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Note: property validationMessage read-only inherited |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# Note: property validity read-only inherited |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# Note: property value |
83
|
|
|
|
|
|
|
{ |
84
|
3
|
|
|
3
|
|
27
|
no warnings 'redefine'; |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
279
|
|
85
|
1
|
|
|
1
|
|
773
|
sub value : lvalue { return( shift->textContent( @_ ) ); } |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# Note: property willValidate read-only inherited |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
# NOTE: POD |
92
|
|
|
|
|
|
|
__END__ |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=encoding utf-8 |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 NAME |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
HTML::Object::DOM::Element::Output - HTML Object DOM Output Class |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 SYNOPSIS |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
use HTML::Object::DOM::Element::Output; |
103
|
|
|
|
|
|
|
my $output = HTML::Object::DOM::Element::Output->new || |
104
|
|
|
|
|
|
|
die( HTML::Object::DOM::Element::Output->error, "\n" ); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 VERSION |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
v0.2.0 |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 DESCRIPTION |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This interface provides properties and methods (beyond those inherited from L<HTML::Object::Element>) for manipulating the layout and presentation of C<<output>> elements. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 INHERITANCE |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
+-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +------------------------------------+ |
117
|
|
|
|
|
|
|
| HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Output | |
118
|
|
|
|
|
|
|
+-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +------------------------------------+ |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 PROPERTIES |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Inherits properties from its parent L<HTML::Object::DOM::Element> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 defaultValue |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
A string representing the default value of the element, initially the empty string. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement/defaultValue> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 form |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Read-only. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
An L<HTML::Object::DOM::Element::Form> indicating the form associated with the control, reflecting the form HTML attribute if it is defined. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Example: |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
<form |
139
|
|
|
|
|
|
|
action="/action_page.php" |
140
|
|
|
|
|
|
|
id="numform" |
141
|
|
|
|
|
|
|
oninput="x.value=parseInt(a.value)+parseInt(b.value)"> |
142
|
|
|
|
|
|
|
<input type="range" id="a" name="a" value="50" /> |
143
|
|
|
|
|
|
|
+ <input type="number" id="b" name="b" value="25" /> |
144
|
|
|
|
|
|
|
<input type="submit" /> |
145
|
|
|
|
|
|
|
</form> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
<output form="numform" id="x" name="x" for="a b"></output> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement/form> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 htmlFor |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Read-only. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
A L<TokenList|HTML::Object::TokenList> reflecting the for HTML attribute, containing a list of IDs of other elements in the same document that contribute to (or otherwise affect) the calculated value. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement/htmlFor> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 labels |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Read-only. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Returns a L<HTML::Object::DOM::NodeList> of L<<label>|HTML::Object::DOM::Element::Label> elements associated with the element. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Example: |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
<label id="label1" for="test">Label 1</label> |
168
|
|
|
|
|
|
|
<output id="test">Output</output> |
169
|
|
|
|
|
|
|
<label id="label2" for="test">Label 2</label> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
use HTML::Object::DOM qw( window ); |
172
|
|
|
|
|
|
|
window->addEventListener( DOMContentLoaded => sub |
173
|
|
|
|
|
|
|
{ |
174
|
|
|
|
|
|
|
my $output = $doc->getElementById( 'test' ); |
175
|
|
|
|
|
|
|
for( my $i = 0; $i < $output->labels->length; $i++ ) |
176
|
|
|
|
|
|
|
{ |
177
|
|
|
|
|
|
|
say( $output->labels->[$i]->textContent ); # "Label 1" and "Label 2" |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
}); |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement/labels> |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head2 name |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
A string reflecting the name HTML attribute, containing the name for the control that is submitted with form data. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement/name> |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head2 type |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Normally this is read-only, but under perl you can set whatever string value you want. By default the value is C<output>. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Under JavaScript, this is a read-only property that returns the string C<output>. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement/type> |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head2 validationMessage |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Read-only. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
A string representing a localized 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. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement/validationMessage> |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head2 validity |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Read-only. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
A C<ValidityState> representing the validity states that this element is in. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement/validity> |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head2 value |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
A string representing the value of the contents of the elements. Behaves like the L<HTML::Object::DOM::Node/textContent> property. |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement/value> |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head2 willValidate |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Read-only. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
A boolean value indicating whether the element is a candidate for constraint validation. |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement/willValidate> |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 METHODS |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
Inherits methods from its parent L<HTML::Object::DOM::Element> |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head2 checkValidity |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Checks the validity of the element and returns a boolean value holding the check result. |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement/checkValidity> |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head2 reportValidity |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
This method reports the problems with the constraints on the element, if any, to the user. If there are problems, fires an invalid event at the element, and returns false; if there are no problems, it returns true. |
240
|
|
|
|
|
|
|
When the problem is reported, the user agent may focus the element and change the scrolling position of the document or perform some other action that brings the element to the user's attention. User agents may report more than one constraint violation if this element suffers from multiple problems at once. If the element is not rendered, then the user agent may report the error for the running script instead of notifying the user. |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement/reportValidity> |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head2 setCustomValidity |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
Sets a custom validity message for the element. If this message is not the empty string, then the element is suffering from a custom validity error, and does not validate. |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement/setCustomValidity> |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head1 AUTHOR |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=head1 SEE ALSO |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement>, L<Mozilla documentation on output element|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/output> |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
Copyright(c) 2021 DEGUEST Pte. Ltd. |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
All rights reserved |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=cut |