| 1 | ##---------------------------------------------------------------------------- | ||||||||||
| 2 | ## HTML Object - ~/lib/HTML/Object/DOM/Root.pm | ||||||||||
| 3 | ## Version v0.2.0 | ||||||||||
| 4 | ## Copyright(c) 2021 DEGUEST Pte. Ltd. | ||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||
| 6 | ## Created 2021/12/13 | ||||||||||
| 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::Root; | ||||||||||
| 15 | BEGIN | ||||||||||
| 16 | { | ||||||||||
| 17 | 8 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 8 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 8 | ▶ | warnings::register_categories( 'HTML::Object' ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 8 | ▶ | use parent qw( HTML::Object::Root HTML::Object::DOM::Node ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 8 | ▶ | use vars qw( $VERSION ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 8 | our $VERSION = 'v0.2.0'; | |||||||||
| 23 | }; | ||||||||||
| 24 | |||||||||||
| 25 | 8 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 8 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | |||||||||||
| 28 | sub init | ||||||||||
| 29 | { | ||||||||||
| 30 | 0 | ▶ | my $self = shift( @_ ); | ||||||||
|
Subroutine
init: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 31 | 0 | $self->{_init_strict_use_sub} = 1; | |||||||||
| 32 | 0 | ▶ | $self->HTML::Object::Root::init( @_ ) || return( $self->pass_error ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | return( $self ); | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | sub cmp | ||||||||||
| 37 | { | ||||||||||
| 38 | 0 | ▶ | my( $self, $this ) = @_; | ||||||||
|
Subroutine
cmp: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 39 | 0 | ▶ | return( $self->_is_a( $this => 'HTML::Object::Root' ) ? 0 : 1 ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 0 | ▶ | sub getAttributes { return( wantarray() ? () : [] ); } | ||||||||
|
Subroutine
getAttributes: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | sub getChildNodes { return( shift->root ); } | ||||||||
|
Subroutine
getChildNodes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 45 | |||||||||||
| 46 | 0 | ▶ | sub getName { return; } | ||||||||
|
Subroutine
getName: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 47 | |||||||||||
| 48 | 0 | ▶ | sub getNextSibling { return; } | ||||||||
|
Subroutine
getNextSibling: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | sub getParentNode { return; } | ||||||||
|
Subroutine
getParentNode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 51 | |||||||||||
| 52 | 0 | ▶ | sub getPreviousSibling { return; } | ||||||||
|
Subroutine
getPreviousSibling: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 53 | |||||||||||
| 54 | 0 | ▶ | sub getRootNode { return( shift( @_ ) ); } | ||||||||
|
Subroutine
getRootNode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 55 | |||||||||||
| 56 | 0 | ▶ | sub is_inside { return( 0 ); } | ||||||||
|
Subroutine
is_inside: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 57 | |||||||||||
| 58 | 0 | ▶ | sub isDocumentNode { return( 1 ); } | ||||||||
|
Subroutine
isDocumentNode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | sub root { return( shift->_set_get_object( 'root', 'HTML::Object::DOM::Node', @_ ) ); } | ||||||||
|
Subroutine
root: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 61 | |||||||||||
| 62 | 8 | 1; | |||||||||
| 63 | # NOTE: POD | ||||||||||
| 64 | __END__ | ||||||||||
| 65 | |||||||||||
| 66 | =encoding utf-8 | ||||||||||
| 67 | |||||||||||
| 68 | =head1 NAME | ||||||||||
| 69 | |||||||||||
| 70 | HTML::Object::DOM::Root - HTML Object | ||||||||||
| 71 | |||||||||||
| 72 | =head1 SYNOPSIS | ||||||||||
| 73 | |||||||||||
| 74 | use HTML::Object::DOM::Root; | ||||||||||
| 75 | my $this = HTML::Object::DOM::Root->new || die( HTML::Object::DOM::Root->error, "\n" ); | ||||||||||
| 76 | |||||||||||
| 77 | =head1 VERSION | ||||||||||
| 78 | |||||||||||
| 79 | v0.2.0 | ||||||||||
| 80 | |||||||||||
| 81 | =head1 DESCRIPTION | ||||||||||
| 82 | |||||||||||
| 83 | This module implements a Root in DOM. It inherits from L<HTML::Object::Root> and L<HTML::Object::DOM::Node> | ||||||||||
| 84 | |||||||||||
| 85 | =head1 INHERITANCE | ||||||||||
| 86 | |||||||||||
| 87 | +---------------------------+ +-------------------------+ +--------------------+ +-------------------------+ | ||||||||||
| 88 | | HTML::Object::Element | --> | HTML::Object::Document | --> | HTML::Object::Root | --> | HTML::Object::DOM::Root | | ||||||||||
| 89 | +---------------------------+ +-------------------------+ +--------------------+ +-------------------------+ | ||||||||||
| 90 | | ^ | ||||||||||
| 91 | | | | ||||||||||
| 92 | v | | ||||||||||
| 93 | +---------------------------+ +-------------------------+ | | ||||||||||
| 94 | | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | ---------------------------------+ | ||||||||||
| 95 | +---------------------------+ +-------------------------+ | ||||||||||
| 96 | |||||||||||
| 97 | =head1 METHODS | ||||||||||
| 98 | |||||||||||
| 99 | =head2 cmp | ||||||||||
| 100 | |||||||||||
| 101 | Provided with another object and this returns true if the other object is a L<HTML::Object::Root> object or false otherwise. | ||||||||||
| 102 | |||||||||||
| 103 | =head2 getAttributes | ||||||||||
| 104 | |||||||||||
| 105 | Returns an empty list in list context, or an empty array reference in scalar context. | ||||||||||
| 106 | |||||||||||
| 107 | =head2 getChildNodes | ||||||||||
| 108 | |||||||||||
| 109 | Returns the L</root> element. | ||||||||||
| 110 | |||||||||||
| 111 | =head2 getName | ||||||||||
| 112 | |||||||||||
| 113 | Returns an empty list in list context, or C<undef> in scalar context. | ||||||||||
| 114 | |||||||||||
| 115 | =head2 getNextSibling | ||||||||||
| 116 | |||||||||||
| 117 | Returns an empty list in list context, or C<undef> in scalar context. | ||||||||||
| 118 | |||||||||||
| 119 | =head2 getParentNode | ||||||||||
| 120 | |||||||||||
| 121 | Returns an empty list in list context, or C<undef> in scalar context. | ||||||||||
| 122 | |||||||||||
| 123 | =head2 getPreviousSibling | ||||||||||
| 124 | |||||||||||
| 125 | Returns an empty list in list context, or C<undef> in scalar context. | ||||||||||
| 126 | |||||||||||
| 127 | =head2 getRootNode | ||||||||||
| 128 | |||||||||||
| 129 | Returns itself. | ||||||||||
| 130 | |||||||||||
| 131 | =head2 is_inside | ||||||||||
| 132 | |||||||||||
| 133 | Returns false. | ||||||||||
| 134 | |||||||||||
| 135 | =head2 isDocumentNode | ||||||||||
| 136 | |||||||||||
| 137 | Returns true. | ||||||||||
| 138 | |||||||||||
| 139 | =head2 root | ||||||||||
| 140 | |||||||||||
| 141 | Sets or gets a L<root node|HTML::Object::DOM::Node>, which should be a L<HTML::Object::DOM::Element::HTML> object. | ||||||||||
| 142 | |||||||||||
| 143 | =head1 AUTHOR | ||||||||||
| 144 | |||||||||||
| 145 | Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> | ||||||||||
| 146 | |||||||||||
| 147 | =head1 SEE ALSO | ||||||||||
| 148 | |||||||||||
| 149 | L<HTML::Object::DOM::Element::HTML> | ||||||||||
| 150 | |||||||||||
| 151 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 152 | |||||||||||
| 153 | Copyright(c) 2021 DEGUEST Pte. Ltd. | ||||||||||
| 154 | |||||||||||
| 155 | All rights reserved | ||||||||||
| 156 | |||||||||||
| 157 | This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||
| 158 | |||||||||||
| 159 | =cut | ||||||||||