File Coverage

lib/HTML/Object/DOM/Element/TextArea.pm
Criterion Covered Total %
statement 19 26 73.0
branch 0 4 0.0
condition n/a
subroutine 7 10 70.0
pod 3 3 100.0
total 29 43 67.4


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