| 1 | ##---------------------------------------------------------------------------- | ||||||||||||
| 2 | ## HTML Object - ~/lib/HTML/Object/DOM/Element/Link.pm | ||||||||||||
| 3 | ## Version v0.2.0 | ||||||||||||
| 4 | ## Copyright(c) 2021 DEGUEST Pte. Ltd. | ||||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||||
| 6 | ## Created 2021/12/22 | ||||||||||||
| 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::Link; | ||||||||||||
| 15 | BEGIN | ||||||||||||
| 16 | { | ||||||||||||
| 17 | 6 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 18 | 6 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | 6 | ▶ | warnings::register_categories( 'HTML::Object' ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 20 | 6 | ▶ | use parent qw( HTML::Object::DOM::Element ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 21 | 6 | ▶ | use vars qw( $VERSION ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 22 | 6 | ▶ | use HTML::Object::DOM::Element::Shared qw( :link ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 23 | # There are a few properties and methods that are common to AnchorElement class, so | ||||||||||||
| 24 | # instead of re-writing them, we re-use those from AnchorElement. | ||||||||||||
| 25 | 6 | require HTML::Object::DOM::Element::Anchor; | |||||||||||
| 26 | 6 | our $VERSION = 'v0.2.0'; | |||||||||||
| 27 | }; | ||||||||||||
| 28 | |||||||||||||
| 29 | 6 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 30 | 6 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 31 | |||||||||||||
| 32 | sub init | ||||||||||||
| 33 | { | ||||||||||||
| 34 | 19 | ▶ | my $self = shift( @_ ); | ||||||||||
|
Subroutine
init: called CC=3 SCAR=16.2
Pod
documented
| |||||||||||||
| 35 | 19 | $self->{_init_strict_use_sub} = 1; | |||||||||||
| 36 | 19 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 37 | 19 | ▶ | $self->{tag} = 'link' if( !CORE::length( "$self->{tag}" ) ); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 38 | $self->_set_get_internal_attribute_callback( rel => sub | ||||||||||||
| 39 | { | ||||||||||||
| 40 | 0 | ▶ | my( $this, $val ) = @_; | ||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||
| 41 | 0 | my $list; | |||||||||||
| 42 | 0 | ▶ | return if( !( $list = $this->{_rel_list} ) ); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 43 | # $list->debug( $self->debug ); | ||||||||||||
| 44 | 0 | $list->update( $val ); | |||||||||||
| 45 | 19 | }); | |||||||||||
| 46 | $self->_set_get_internal_attribute_callback( sizes => sub | ||||||||||||
| 47 | { | ||||||||||||
| 48 | 0 | ▶ | my( $this, $val ) = @_; | ||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||
| 49 | 0 | my $list; | |||||||||||
| 50 | 0 | ▶ | return if( !( $list = $this->{_sizes_list} ) ); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 51 | # $list->debug( $self->debug ); | ||||||||||||
| 52 | 0 | $list->update( $val ); | |||||||||||
| 53 | 19 | }); | |||||||||||
| 54 | 19 | return( $self ); | |||||||||||
| 55 | } | ||||||||||||
| 56 | |||||||||||||
| 57 | # Note: property | ||||||||||||
| 58 | 0 | ▶ | sub as : lvalue { return( shift->_set_get_property( 'as', @_ ) ); } | ||||||||||
|
Subroutine
as: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 59 | |||||||||||||
| 60 | # Note: property crossOrigin inherited | ||||||||||||
| 61 | |||||||||||||
| 62 | # Note: property disabled inherited | ||||||||||||
| 63 | |||||||||||||
| 64 | # Note: property href inherited | ||||||||||||
| 65 | |||||||||||||
| 66 | # Note: property hreflang inherited | ||||||||||||
| 67 | |||||||||||||
| 68 | # Note: property | ||||||||||||
| 69 | 0 | ▶ | sub media : lvalue { return( shift->_set_get_property( 'media', @_ ) ); } | ||||||||||
|
Subroutine
media: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 70 | |||||||||||||
| 71 | # Note: property referrerPolicy inherited | ||||||||||||
| 72 | |||||||||||||
| 73 | # Note: property rel inherited | ||||||||||||
| 74 | |||||||||||||
| 75 | # Note: property relList inherited | ||||||||||||
| 76 | |||||||||||||
| 77 | # Note: property | ||||||||||||
| 78 | sub sizes | ||||||||||||
| 79 | { | ||||||||||||
| 80 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||
|
Subroutine
sizes: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 81 | 0 | ▶ | unless( $self->{_sizes_list} ) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 82 | { | ||||||||||||
| 83 | 0 | my $sizes = $self->attr( 'sizes' ); | |||||||||||
| 84 | 0 | require HTML::Object::TokenList; | |||||||||||
| 85 | 0 | ▶ | $self->{_sizes_list} = HTML::Object::TokenList->new( $sizes, element => $self, attribute => 'sizes', debug => $self->debug ) || | ||||||||||
|
Condition0%0/2
'HTML::Object::TokenList'->new($sizes, 'element', $self, 'attribute', 'sizes', 'debug', $self->debug) || (return $self->pass_error('HTML::Object::TokenList'->error))
MC/DC0%0/1
'HTML::Object::TokenList'->new($sizes, 'element', $self, 'attribute', 'sizes', 'debug', $self->debug) || (return $self->pass_error('HTML::Object::TokenList'->error))
'HTML::Object::TokenList'->new($sizes, 'element', $self, 'attribute', 'sizes', 'debug', $self->debug)
Truth table0%0/2
A
A= 'HTML::Object::TokenList'->new($sizes, 'element', $self, 'attribute', 'sizes', 'debug', $self->debug)
| |||||||||||||
| 86 | return( $self->pass_error( HTML::Object::TokenList->error ) ); | ||||||||||||
| 87 | } | ||||||||||||
| 88 | 0 | return( $self->{_sizes_list} ); | |||||||||||
| 89 | } | ||||||||||||
| 90 | |||||||||||||
| 91 | # TODO: make call to this method return a CSS::Object | ||||||||||||
| 92 | # Note: property | ||||||||||||
| 93 | 0 | ▶ | sub sheet { return; } | ||||||||||
|
Subroutine
sheet: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 94 | |||||||||||||
| 95 | # Note: property type inherited | ||||||||||||
| 96 | |||||||||||||
| 97 | 6 | 1; | |||||||||||
| 98 | # NOTE: POD | ||||||||||||
| 99 | __END__ | ||||||||||||
| 100 | |||||||||||||
| 101 | =encoding utf-8 | ||||||||||||
| 102 | |||||||||||||
| 103 | =head1 NAME | ||||||||||||
| 104 | |||||||||||||
| 105 | HTML::Object::DOM::Element::Link - HTML Object DOM Link Class | ||||||||||||
| 106 | |||||||||||||
| 107 | =head1 SYNOPSIS | ||||||||||||
| 108 | |||||||||||||
| 109 | use HTML::Object::DOM::Element::Link; | ||||||||||||
| 110 | my $link = HTML::Object::DOM::Element::Link->new || | ||||||||||||
| 111 | die( HTML::Object::DOM::Element::Link->error, "\n" ); | ||||||||||||
| 112 | |||||||||||||
| 113 | =head1 VERSION | ||||||||||||
| 114 | |||||||||||||
| 115 | v0.2.0 | ||||||||||||
| 116 | |||||||||||||
| 117 | =head1 DESCRIPTION | ||||||||||||
| 118 | |||||||||||||
| 119 | The C<LinkElement> interface represents reference information for external resources and the relationship of those resources to a document and vice-versa (corresponds to <link> element; not to be confused with <a>, which is represented by L<HTML::Object::DOM::Element::Anchor>). This object inherits all of the properties and methods of the L<HTML::Object::DOM::Element> interface. | ||||||||||||
| 120 | |||||||||||||
| 121 | =head1 INHERITANCE | ||||||||||||
| 122 | |||||||||||||
| 123 | +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +----------------------------------+ | ||||||||||||
| 124 | | HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Link | | ||||||||||||
| 125 | +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +----------------------------------+ | ||||||||||||
| 126 | |||||||||||||
| 127 | =head1 PROPERTIES | ||||||||||||
| 128 | |||||||||||||
| 129 | Inherits properties from its parent L<HTML::Object::DOM::DOM::Element> | ||||||||||||
| 130 | |||||||||||||
| 131 | =head2 as | ||||||||||||
| 132 | |||||||||||||
| 133 | A string representing the type of content being loaded by the HTML link. | ||||||||||||
| 134 | |||||||||||||
| 135 | Example: | ||||||||||||
| 136 | |||||||||||||
| 137 | <link rel="preload" href="myFont.woff2" as="font" | ||||||||||||
| 138 | type="font/woff2" crossorigin="anonymous"> | ||||||||||||
| 139 | |||||||||||||
| 140 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/as> | ||||||||||||
| 141 | |||||||||||||
| 142 | =head2 crossOrigin | ||||||||||||
| 143 | |||||||||||||
| 144 | A string that corresponds to the CORS setting for this link element. See CORS settings attributes for details. | ||||||||||||
| 145 | |||||||||||||
| 146 | Example: | ||||||||||||
| 147 | |||||||||||||
| 148 | <link rel="preload" href="myFont.woff2" as="font" | ||||||||||||
| 149 | type="font/woff2" crossorigin="anonymous"> | ||||||||||||
| 150 | |||||||||||||
| 151 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/crossOrigin> | ||||||||||||
| 152 | |||||||||||||
| 153 | =head2 disabled | ||||||||||||
| 154 | |||||||||||||
| 155 | A boolean value which represents whether the link is disabled; currently only used with style sheet links. | ||||||||||||
| 156 | |||||||||||||
| 157 | If the boolean value provided is false, the disabled property will be removed altogether. If it is true, it will be set to an empty value. | ||||||||||||
| 158 | |||||||||||||
| 159 | Example: | ||||||||||||
| 160 | |||||||||||||
| 161 | my $link = $doc->createElement( 'link' ); | ||||||||||||
| 162 | $link->disabled = 1; | ||||||||||||
| 163 | # <link disabled="" /> | ||||||||||||
| 164 | $link->disabled = 0; | ||||||||||||
| 165 | # <link /> | ||||||||||||
| 166 | |||||||||||||
| 167 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/disabled> | ||||||||||||
| 168 | |||||||||||||
| 169 | =head2 href | ||||||||||||
| 170 | |||||||||||||
| 171 | A string representing the URI for the target resource. | ||||||||||||
| 172 | |||||||||||||
| 173 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/href> | ||||||||||||
| 174 | |||||||||||||
| 175 | =head2 hreflang | ||||||||||||
| 176 | |||||||||||||
| 177 | A string representing the language code for the linked resource. | ||||||||||||
| 178 | |||||||||||||
| 179 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/hreflang> | ||||||||||||
| 180 | |||||||||||||
| 181 | =head2 media | ||||||||||||
| 182 | |||||||||||||
| 183 | A string representing a list of one or more media formats to which the resource applies. | ||||||||||||
| 184 | |||||||||||||
| 185 | Example: | ||||||||||||
| 186 | |||||||||||||
| 187 | <link href="print.css" rel="stylesheet" media="print" /> | ||||||||||||
| 188 | <link href="mobile.css" rel="stylesheet" media="screen and (max-width: 600px)" /> | ||||||||||||
| 189 | |||||||||||||
| 190 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/media> | ||||||||||||
| 191 | |||||||||||||
| 192 | =head2 referrerPolicy | ||||||||||||
| 193 | |||||||||||||
| 194 | A string that reflects the referrerpolicy HTML attribute indicating which referrer to use. | ||||||||||||
| 195 | |||||||||||||
| 196 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/referrerPolicy> | ||||||||||||
| 197 | |||||||||||||
| 198 | =head2 rel | ||||||||||||
| 199 | |||||||||||||
| 200 | A string representing the forward relationship of the linked resource from the document to the resource. | ||||||||||||
| 201 | |||||||||||||
| 202 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/rel> | ||||||||||||
| 203 | |||||||||||||
| 204 | =head2 relList | ||||||||||||
| 205 | |||||||||||||
| 206 | Read-only. | ||||||||||||
| 207 | |||||||||||||
| 208 | A L<HTML::Object::TokenList> that reflects the rel HTML attribute, as a L<list of tokens|HTML::Object::DOM::TokenList>. | ||||||||||||
| 209 | |||||||||||||
| 210 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/relList> | ||||||||||||
| 211 | |||||||||||||
| 212 | =head2 sizes | ||||||||||||
| 213 | |||||||||||||
| 214 | Read-only. | ||||||||||||
| 215 | |||||||||||||
| 216 | A L<HTML::Object::TokenList> that reflects the sizes HTML attribute, as a L<list of tokens|HTML::Object::DOM::TokenList>. | ||||||||||||
| 217 | |||||||||||||
| 218 | <link rel="apple-touch-icon-precomposed" sizes="114x114" | ||||||||||||
| 219 | href="apple-icon-114.png" type="image/png"> | ||||||||||||
| 220 | |||||||||||||
| 221 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/sizes> | ||||||||||||
| 222 | |||||||||||||
| 223 | =head2 sheet | ||||||||||||
| 224 | |||||||||||||
| 225 | Read-only. | ||||||||||||
| 226 | |||||||||||||
| 227 | This currently always returns C<undef>. Maybe in the future this would return a L<CSS::Object> object. | ||||||||||||
| 228 | |||||||||||||
| 229 | Normally, under JavaScript environment, this would return the L<StyleSheet object|https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet> associated with the given element, or C<undef> if there is none. | ||||||||||||
| 230 | |||||||||||||
| 231 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/sheet> and also the L<CSSObject documentation|https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet> | ||||||||||||
| 232 | |||||||||||||
| 233 | =head2 type | ||||||||||||
| 234 | |||||||||||||
| 235 | A string representing the MIME type of the linked resource. | ||||||||||||
| 236 | |||||||||||||
| 237 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/type> | ||||||||||||
| 238 | |||||||||||||
| 239 | =head1 METHODS | ||||||||||||
| 240 | |||||||||||||
| 241 | No specific method; inherits methods from its parent, L<HTML::Object::DOM::DOM::Element> | ||||||||||||
| 242 | |||||||||||||
| 243 | =head1 AUTHOR | ||||||||||||
| 244 | |||||||||||||
| 245 | Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> | ||||||||||||
| 246 | |||||||||||||
| 247 | =head1 SEE ALSO | ||||||||||||
| 248 | |||||||||||||
| 249 | L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement>, L<specification on link|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link> | ||||||||||||
| 250 | |||||||||||||
| 251 | =head1 COPYRIGHT & LICENSE | ||||||||||||
| 252 | |||||||||||||
| 253 | Copyright(c) 2021 DEGUEST Pte. Ltd. | ||||||||||||
| 254 | |||||||||||||
| 255 | All rights reserved | ||||||||||||
| 256 | |||||||||||||
| 257 | This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||||
| 258 | |||||||||||||
| 259 | =cut | ||||||||||||