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

filter: Statementstmt 0.0% 0 / 28 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 46 CC 2 SCAR 10.0
CC
2
Cov
0%
init
6.0
BEGIN
2.0
oninput
2.0
CRAP 2.7
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/DOM/Element/TextArea.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2022 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2022/01/09
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::TextArea;
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 our $VERSION = 'v0.2.0';
23 };
24  
25 use strict;
26 use warnings;
27  
28 sub init
29 {
30 my $self = shift( @_ );
31 $self->{_init_strict_use_sub} = 1;
32 $self->SUPER::init( @_ ) || return( $self->pass_error );
33 $self->{tag} = 'textarea' if( !CORE::length( "$self->{tag}" ) );
34 return( $self );
35 }
36  
37 sub oninput : lvalue { return( shift->on( 'input', @_ ) ); }
38  
39 sub onselectionchange : lvalue { return( shift->on( 'selectionchange', @_ ) ); }
40  
41 1;
42 # NOTE: POD
43 __END__
44  
45 =encoding utf-8
46  
47 =head1 NAME
48  
49 HTML::Object::DOM::Element::TextArea - HTML Object DOM TextArea Class
50  
51 =head1 SYNOPSIS
52  
53 use HTML::Object::DOM::Element::TextArea;
54 my $textarea = HTML::Object::DOM::Element::TextArea->new ||
55 die( HTML::Object::DOM::Element::TextArea->error, "\n" );
56  
57 =head1 VERSION
58  
59 v0.2.0
60  
61 =head1 DESCRIPTION
62  
63 This interface provides special properties and methods for manipulating the layout and presentation of <textarea> elements.
64  
65 =head1 INHERITANCE
66  
67 +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +--------------------------------------+
68 | HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::TextArea |
69 +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +--------------------------------------+
70  
71 =head1 PROPERTIES
72  
73 Inherits properties from its parent L<HTML::Object::DOM::Element>
74  
75 =head1 METHODS
76  
77 Inherits methods from its parent L<HTML::Object::DOM::Element>
78  
79 =head1 EVENTS
80  
81 Event listeners for those events can also be found by prepending C<on> before the event type:
82  
83 C<click> event listeners can be set also with C<onclick> method:
84  
85 $e->onclick(sub{ # do something });
86 # or as an lvalue method
87 $e->onclick = sub{ # do something };
88  
89 =head2 input
90  
91 Fires when the value of an L<input|HTML::Object::DOM::Element::Input>, L<select|HTML::Object::DOM::Element::Select>, or L<textarea|HTML::Object::DOM::Element::TextArea> element has been changed.
92  
93 Example:
94  
95 <input placeholder="Enter some text" name="name"/>
96 <p id="values"></p>
97  
98 my $input = $doc->querySelector('$input');
99 my $log = $doc->getElementById('values');
100  
101 $input->addEventListener( input => \&updateValue );
102  
103 sub updateValue
104 {
105 my $e = shift( @_ );
106 $log->textContent = $e->target->value;
107 }
108  
109 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event>
110  
111 =head2 selectionchange
112  
113 Under perl, this does not do anything of course, but you can fire yourself the event.
114  
115 Under JavaScript, this fires when the text selection in a L<textarea|HTML::Object::DOM::Element::TextArea> element has been changed.
116  
117 Example:
118  
119 <div>Enter and select text here:<br><textarea id="mytext" rows="2" cols="20"></textarea></div>
120 <div>selectionStart: <span id="start"></span></div>
121 <div>selectionEnd: <span id="end"></span></div>
122 <div>selectionDirection: <span id="direction"></span></div>
123  
124 my $myinput = $doc->getElementById( 'mytext' );
125  
126 $myinput->addEventListener( selectionchange => sub
127 {
128 $doc->getElementById( 'start' )->textContent = $mytext->selectionStart;
129 $doc->getElementById( 'end' )->textContent = $mytext->selectionEnd;
130 $doc->getElementById( 'direction' )->textContent = $mytext->selectionDirection;
131 });
132  
133 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement/selectionchange_event>
134  
135 =head2 EVENT HANDLERS
136  
137 =head2 oninput
138  
139 Property to handle event of type C<input>. Those events are not automatically fired, but you can trigger them yourself.
140  
141 =head2 onselectionchange
142  
143 Property to handle event of type C<selectionchange>. Those events are not automatically fired, but you can trigger them yourself.
144  
145 =head1 AUTHOR
146  
147 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
148  
149 =head1 SEE ALSO
150  
151 L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement>, L<Mozilla documentation on textarea element|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea>
152  
153 =head1 COPYRIGHT & LICENSE
154  
155 Copyright(c) 2022 DEGUEST Pte. Ltd.
156  
157 All rights reserved
158  
159 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
160  
161 =cut