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