| 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 | use strict; | ||
| 18 | use warnings; | ||
| 19 | warnings::register_categories( 'HTML::Object' ); | ||
| 20 | use parent qw( HTML::Object::Root HTML::Object::DOM::Node ); | ||
| 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->HTML::Object::Root::init( @_ ) || return( $self->pass_error ); | ||
| 33 | return( $self ); | ||
| 34 | } | ||
| 35 | |||
| 36 | sub cmp | ||
| 37 | { | ||
| 38 | my( $self, $this ) = @_; | ||
| 39 | return( $self->_is_a( $this => 'HTML::Object::Root' ) ? 0 : 1 ); | ||
| 40 | } | ||
| 41 | |||
| 42 | sub getAttributes { return( wantarray() ? () : [] ); } | ||
| 43 | |||
| 44 | sub getChildNodes { return( shift->root ); } | ||
| 45 | |||
| 46 | sub getName { return; } | ||
| 47 | |||
| 48 | sub getNextSibling { return; } | ||
| 49 | |||
| 50 | sub getParentNode { return; } | ||
| 51 | |||
| 52 | sub getPreviousSibling { return; } | ||
| 53 | |||
| 54 | sub getRootNode { return( shift( @_ ) ); } | ||
| 55 | |||
| 56 | sub is_inside { return( 0 ); } | ||
| 57 | |||
| 58 | sub isDocumentNode { return( 1 ); } | ||
| 59 | |||
| 60 | sub root { return( shift->_set_get_object( 'root', 'HTML::Object::DOM::Node', @_ ) ); } | ||
| 61 | |||
| 62 | 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 |