line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
## HTML Object - ~/lib/HTML/Object/DOM/Element/Template.pm |
3
|
|
|
|
|
|
|
## Version v0.2.0 |
4
|
|
|
|
|
|
|
## Copyright(c) 2022 DEGUEST Pte. Ltd. |
5
|
|
|
|
|
|
|
## Author: Jacques Deguest <jack@deguest.jp> |
6
|
|
|
|
|
|
|
## Created 2022/01/09 |
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::Template; |
15
|
|
|
|
|
|
|
BEGIN |
16
|
|
|
|
|
|
|
{ |
17
|
1
|
|
|
1
|
|
1054
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
18
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
31
|
|
19
|
1
|
|
|
1
|
|
6
|
use parent qw( HTML::Object::DOM::Element ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
20
|
1
|
|
|
1
|
|
71
|
use vars qw( $VERSION ); |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
68
|
|
21
|
1
|
|
|
1
|
|
20
|
our $VERSION = 'v0.2.0'; |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
34
|
|
25
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
355
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub init |
28
|
|
|
|
|
|
|
{ |
29
|
0
|
|
|
0
|
1
|
|
my $self = shift( @_ ); |
30
|
0
|
|
|
|
|
|
$self->{_init_strict_use_sub} = 1; |
31
|
0
|
0
|
|
|
|
|
$self->SUPER::init( @_ ) || return( $self->pass_error ); |
32
|
0
|
0
|
|
|
|
|
$self->{tag} = 'template' if( !CORE::length( "$self->{tag}" ) ); |
33
|
0
|
|
|
|
|
|
return( $self ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Note: property content read-only |
37
|
|
|
|
|
|
|
sub content : lvalue { return( shift->_lvalue({ |
38
|
|
|
|
|
|
|
set => sub |
39
|
|
|
|
|
|
|
{ |
40
|
0
|
|
|
0
|
|
|
my $self = shift( @_ ); |
41
|
0
|
|
|
|
|
|
my $ref = shift( @_ ); |
42
|
0
|
|
0
|
|
|
|
my $nodes = $self->_list_to_nodes( @$ref ) || |
43
|
|
|
|
|
|
|
return( $self->pass_error ); |
44
|
0
|
|
|
|
|
|
for( @$nodes ) |
45
|
|
|
|
|
|
|
{ |
46
|
0
|
|
|
|
|
|
$_->detach; |
47
|
0
|
|
|
|
|
|
$_->parent( $self ); |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
my $children = $self->children; |
50
|
0
|
|
|
|
|
|
$children->set( $nodes ); |
51
|
0
|
|
|
|
|
|
return( $self ); |
52
|
|
|
|
|
|
|
}, |
53
|
|
|
|
|
|
|
get => sub |
54
|
|
|
|
|
|
|
{ |
55
|
0
|
|
|
0
|
|
|
my $self = shift( @_ ); |
56
|
0
|
0
|
|
|
|
|
$self->_load_class( 'HTML::Object::DOM::DocumentFragment' ) || |
57
|
|
|
|
|
|
|
return( $self->pass_error ); |
58
|
0
|
|
|
|
|
|
my $children = $self->children; |
59
|
0
|
|
|
|
|
|
my $frag = HTML::Object::DOM::DocumentFragment->new; |
60
|
0
|
|
|
|
|
|
$frag->children->set( $children ); |
61
|
0
|
|
|
|
|
|
return( $frag ); |
62
|
|
|
|
|
|
|
} |
63
|
0
|
|
|
0
|
1
|
|
}, @_ ) ); } |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
# NOTE: POD |
67
|
|
|
|
|
|
|
__END__ |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=encoding utf-8 |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 NAME |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
HTML::Object::DOM::Element::Template - HTML Object DOM Template Class |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 SYNOPSIS |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
use HTML::Object::DOM::Element::Template; |
78
|
|
|
|
|
|
|
my $template = HTML::Object::DOM::Element::Template->new || |
79
|
|
|
|
|
|
|
die( HTML::Object::DOM::Element::Template->error, "\n" ); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 VERSION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
v0.2.0 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 DESCRIPTION |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This interface enables access to the contents of an HTML C<template> element. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 INHERITANCE |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
+-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +--------------------------------------+ |
92
|
|
|
|
|
|
|
| HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Template | |
93
|
|
|
|
|
|
|
+-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +--------------------------------------+ |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 PROPERTIES |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Inherits properties from its parent L<HTML::Object::DOM::Element> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 content |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Read-only. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
A read-only L<DocumentFragment|HTML::Object::DOM::DocumentFragment> which contains the DOM subtree representing the <template> element's template contents. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Example: |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my $templateElement = $doc->querySelector('#foo'); |
108
|
|
|
|
|
|
|
my $documentFragment = $templateElement->content->cloneNode(1); # pass true to cloneNode |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTemplateElement/content> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 METHODS |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Inherits methods from its parent L<HTML::Object::DOM::Element> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 AUTHOR |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 SEE ALSO |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTemplateElement>, L<Mozilla documentation on template element|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Copyright(c) 2022 DEGUEST Pte. Ltd. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
All rights reserved |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |