File Coverage

lib/HTML/Object/DOM/Element/Body.pm
Criterion Covered Total %
statement 24 47 51.0
branch 2 4 50.0
condition n/a
subroutine 8 31 25.8
pod 24 24 100.0
total 58 106 54.7


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## HTML Object - ~/lib/HTML/Object/DOM/Element/Body.pm
3             ## Version v0.2.0
4             ## Copyright(c) 2022 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2022/01/05
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::Body;
15             BEGIN
16             {
17 14     14   13793 use strict;
  14         55  
  14         776  
18 14     14   144 use warnings;
  14         128  
  14         696  
19 14     14   123 use parent qw( HTML::Object::DOM::Element );
  14         40  
  14         135  
20 14     14   1580 use vars qw( $VERSION );
  14         38  
  14         1404  
21 14     14   399 our $VERSION = 'v0.2.0';
22             };
23              
24 14     14   103 use strict;
  14         48  
  14         422  
25 14     14   80 use warnings;
  14         33  
  14         9873  
26              
27             sub init
28             {
29 18     18 1 1734 my $self = shift( @_ );
30 18         2338 $self->{_init_strict_use_sub} = 1;
31 18 50       226 $self->SUPER::init( @_ ) || return( $self->pass_error );
32 18 50       109 $self->{tag} = 'body' if( !CORE::length( "$self->{tag}" ) );
33 18         243 return( $self );
34             }
35              
36             # Note: property aLink obsolete
37 0     0 1   sub aLink { return; }
38              
39             # Note: property background obsolete
40 0     0 1   sub background { return; }
41              
42             # Note: property bgColor obsolete
43 0     0 1   sub bgColor { return; }
44              
45             # Note: property link obsolete
46 0     0 1   sub link { return; }
47              
48 0     0 1   sub onafterprint : lvalue { return( shift->on( 'afterprint', @_ ) ); }
49              
50 0     0 1   sub onbeforeprint : lvalue { return( shift->on( 'beforeprint', @_ ) ); }
51              
52 0     0 1   sub onbeforeunload : lvalue { return( shift->on( 'beforeunload', @_ ) ); }
53              
54 0     0 1   sub onhashchange : lvalue { return( shift->on( 'hashchange', @_ ) ); }
55              
56 0     0 1   sub onlanguagechange : lvalue { return( shift->on( 'languagechange', @_ ) ); }
57              
58 0     0 1   sub onmessage : lvalue { return( shift->on( 'message', @_ ) ); }
59              
60 0     0 1   sub onmessageerror : lvalue { return( shift->on( 'messageerror', @_ ) ); }
61              
62 0     0 1   sub onoffline : lvalue { return( shift->on( 'offline', @_ ) ); }
63              
64 0     0 1   sub ononline : lvalue { return( shift->on( 'online', @_ ) ); }
65              
66 0     0 1   sub onpagehide : lvalue { return( shift->on( 'pagehide', @_ ) ); }
67              
68 0     0 1   sub onpageshow : lvalue { return( shift->on( 'pageshow', @_ ) ); }
69              
70 0     0 1   sub onpopstate : lvalue { return( shift->on( 'popstate', @_ ) ); }
71              
72 0     0 1   sub onrejectionhandled : lvalue { return( shift->on( 'rejectionhandled', @_ ) ); }
73              
74 0     0 1   sub onresize : lvalue { return( shift->on( 'resize', @_ ) ); }
75              
76 0     0 1   sub onstorage : lvalue { return( shift->on( 'storage', @_ ) ); }
77              
78 0     0 1   sub onunhandledrejection : lvalue { return( shift->on( 'unhandledrejection', @_ ) ); }
79              
80 0     0 1   sub onunload : lvalue { return( shift->on( 'unload', @_ ) ); }
81              
82             # Note: property text obsolete
83 0     0 1   sub text { return; }
84              
85             # Note: property vLink obsolete
86 0     0 1   sub vLink { return; }
87              
88             1;
89             # NOTE: POD
90             __END__
91              
92             =encoding utf-8
93              
94             =head1 NAME
95              
96             HTML::Object::DOM::Element::Body - HTML Object DOM Body Class
97              
98             =head1 SYNOPSIS
99              
100             use HTML::Object::DOM::Element::Body;
101             my $body = HTML::Object::DOM::Element::Body->new ||
102             die( HTML::Object::DOM::Element::Body->error, "\n" );
103              
104             =head1 VERSION
105              
106             v0.2.0
107              
108             =head1 INHERITANCE
109              
110             +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +----------------------------------+
111             | HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Body |
112             +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +----------------------------------+
113              
114             =head1 DESCRIPTION
115              
116             The L<HTML::Object::DOM::Element::Body> interface provides special properties (beyond those inherited from the regular L<HTML::Object::DOM::Element> interface) for manipulating C<<body>> elements.
117              
118             =head1 PROPERTIES
119              
120             Inherits properties from its parent L<HTML::Object::DOM::Element>
121              
122             =head1 OBSOLETE PROPERTIES
123              
124             Those properties all return C<undef>
125              
126             =head2 aLink
127              
128             Is a string that represents the color of active hyperlinks.
129              
130             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/aLink>
131              
132             =head2 background
133              
134             Is a string that represents the description of the location of the background image resource. Note that this is not an URI, though some older version of some browsers do expect it.
135              
136             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/background>
137              
138             =head2 bgColor
139              
140             Is a string that represents the background color for the document.
141              
142             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/bgColor>
143              
144             =head2 link
145              
146             Is a string that represents the color of unvisited links.
147              
148             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/link>
149              
150             =head2 text
151              
152             Is a string that represents the foreground color of text.
153              
154             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/text>
155              
156             =head2 vLink
157              
158             Is a string that represents the color of visited links.
159              
160             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/vLink>
161              
162             =head1 METHODS
163              
164             Inherits methods from its parent L<HTML::Object::DOM::Element>
165              
166             =head1 EVENT HANDLERS
167              
168             Below are the event handlers you can use and that are implemented in this interface. However, it is up to you to fire those related events.
169              
170             =head2 onafterprint
171              
172             Is an event handler representing the code to be called when the afterprint event is raised.
173              
174             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onafterprint>
175              
176             =head2 onbeforeprint
177              
178             Is an event handler representing the code to be called when the beforeprint event is raised.
179              
180             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeprint>
181              
182             =head2 onbeforeunload
183              
184             Is an event handler representing the code to be called when the beforeunload event is raised.
185              
186             Example:
187              
188             use HTML::Object::DOM qw( window );
189             window->addEventListener( beforeunload => sub
190             {
191             # Cancel the event
192             # If you prevent default behavior in Mozilla Firefox prompt will always be shown
193             $e->preventDefault();
194             # Chrome requires returnValue to be set
195             $e->returnValue = '';
196             });
197              
198             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload>
199              
200             =head2 onhashchange
201              
202             Is an event handler representing the code to be called when the hashchange event is raised.
203              
204             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onhashchange>
205              
206             =head2 onlanguagechange
207              
208             Is an event handler representing the code to be called when the languagechange event is raised.
209              
210             Example:
211              
212             object->onlanguagechange = function;
213              
214             window->onlanguagechange = sub
215             {
216             say( 'languagechange event detected!' );
217             };
218              
219             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onlanguagechange>
220              
221             =head2 onmessage
222              
223             Is an event handler called whenever an object receives a message event.
224              
225             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onmessage>
226              
227             =head2 onmessageerror
228              
229             Is an event handler called whenever an object receives a messageerror event.
230              
231             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onmessageerror>
232              
233             =head2 onoffline
234              
235             Is an event handler representing the code to be called when the offline event is raised.
236              
237             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/onoffline>
238              
239             =head2 ononline
240              
241             Is an event handler representing the code to be called when the online event is raised.
242              
243             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/ononline>
244              
245             =head2 onpagehide
246              
247             Is an event handler representing the code to be called when the pagehide event is raised.
248              
249             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/onpagehide>
250              
251             =head2 onpageshow
252              
253             Is an event handler representing the code to be called when the pageshow event is raised.
254              
255             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/onpageshow>
256              
257             =head2 onpopstate
258              
259             Is an event handler representing the code to be called when the popstate event is raised.
260              
261             Example:
262              
263             window->onpopstate = sub
264             {
265             my $event = shift( @_ );
266             say( "location: " . $doc->location . ", state: " . JSON->new->encode( $event->state ) );
267             };
268              
269             $history->pushState({page => 1}, "title 1", "?page=1");
270             $history->pushState({page => 2}, "title 2", "?page=2");
271             $history->replaceState({page => 3}, "title 3", "?page=3");
272             $history->back(); # alerts "location: https://example.org/example.html?page=1, state => {"page" => 1}"
273             $history->back(); # alerts "location: https://example.org/example.html, state: null
274             $history->go(2); # alerts "location: https://example.org/example.html?page=3, state => {"page" =>3}
275              
276             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onpopstate>
277              
278             =head2 onrejectionhandled
279              
280             An event handler representing the code executed when the C<rejectionhandled> event is raised, indicating that a C<Promise> was rejected and the rejection has been handled.
281              
282             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onrejectionhandled>
283              
284             =head2 onresize
285              
286             Is an event handler representing the code to be called when the C<resize> event is raised.
287              
288             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onresize>
289              
290             =head2 onstorage
291              
292             Is an event handler representing the code to be called when the storage event is raised.
293              
294             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onstorage>
295              
296             =head2 onunhandledrejection
297              
298             An event handler representing the code executed when the unhandledrejection event is raised, indicating that a Promise was rejected but the rejection was not handled.
299              
300             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onunhandledrejection>
301              
302             =head2 onunload
303              
304             Is an event handler representing the code to be called when the unload event is raised.
305              
306             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onunload>
307              
308             =head1 AUTHOR
309              
310             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
311              
312             =head1 SEE ALSO
313              
314             L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement>, L<Mozilla documentation on anchor element|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body>
315              
316             =head1 COPYRIGHT & LICENSE
317              
318             Copyright(c) 2022 DEGUEST Pte. Ltd.
319              
320             All rights reserved
321              
322             This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
323              
324             =cut