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