| 1 | ##---------------------------------------------------------------------------- | ||||||||||
| 2 | ## HTML Object - ~/lib/HTML/Object/DOM/DocumentFragment.pm | ||||||||||
| 3 | ## Version v0.2.0 | ||||||||||
| 4 | ## Copyright(c) 2021 DEGUEST Pte. Ltd. | ||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||
| 6 | ## Created 2021/12/20 | ||||||||||
| 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::DocumentFragment; | ||||||||||
| 15 | BEGIN | ||||||||||
| 16 | 2 | ▶ | { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 2 | warnings::register_categories( 'HTML::Object' ); | |||||||||
| 20 | 2 | ▶ | use parent qw( HTML::Object::DOM::Node ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 2 | ▶ | use vars qw( $VERSION ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 2 | our $VERSION = 'v0.2.0'; | |||||||||
| 23 | }; | ||||||||||
| 24 | |||||||||||
| 25 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | sub append { return( shift->_element_method( 'append', @_ ) ); } | ||||||||
|
Subroutine
append: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 29 | |||||||||||
| 30 | sub as_string | ||||||||||
| 31 | 0 | ▶ | { | ||||||||
|
Subroutine
as_string: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 32 | 0 | my $self = shift( @_ ); | |||||||||
| 33 | 0 | my $a = $self->new_array; | |||||||||
| 34 | # We get the string version of all of our children, except ourself, since a | ||||||||||
| 35 | # document fragment is transparent; has no impact on the dom tree. | ||||||||||
| 36 | $self->children->foreach(sub | ||||||||||
| 37 | 0 | ▶ | { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 38 | 0 | $a->push( $_->as_string ); | |||||||||
| 39 | 0 | }); | |||||||||
| 40 | 0 | return( $a->join( '' )->scalar ); | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | # Note: Property | ||||||||||
| 44 | 0 | ▶ | sub childElementCount { return( shift->_elements->length ); } | ||||||||
|
Subroutine
childElementCount: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 45 | |||||||||||
| 46 | # Note: Property | ||||||||||
| 47 | 0 | ▶ | sub firstElementChild { return( shift->_elements->first ); } | ||||||||
|
Subroutine
firstElementChild: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 48 | |||||||||||
| 49 | 0 | ▶ | sub getElementById { return( shift->_element_method( 'getElementById', @_ ) ); } | ||||||||
|
Subroutine
getElementById: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 50 | |||||||||||
| 51 | # Note: Property | ||||||||||
| 52 | 0 | ▶ | sub lastElementChild { return( shift->_elements->last ); } | ||||||||
|
Subroutine
lastElementChild: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 53 | |||||||||||
| 54 | 2 | ▶ | sub parent { return; } | ||||||||
|
Subroutine
parent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 55 | |||||||||||
| 56 | 0 | ▶ | sub parentNode { return; } | ||||||||
|
Subroutine
parentNode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 57 | |||||||||||
| 58 | 0 | ▶ | sub parentElement { return; } | ||||||||
|
Subroutine
parentElement: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | sub prepend { return( shift->_element_method( 'prepend', @_ ) ); } | ||||||||
|
Subroutine
prepend: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 61 | |||||||||||
| 62 | 0 | ▶ | sub querySelector { return( shift->_element_method( 'querySelector', @_ ) ); } | ||||||||
|
Subroutine
querySelector: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 63 | |||||||||||
| 64 | 0 | ▶ | sub querySelectorAll { return( shift->_element_method( 'querySelectorAll', @_ ) ); } | ||||||||
|
Subroutine
querySelectorAll: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 65 | |||||||||||
| 66 | 0 | ▶ | sub replaceChildren { return( shift->_element_method( 'replaceChildren', @_ ) ); } | ||||||||
|
Subroutine
replaceChildren: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 67 | |||||||||||
| 68 | 0 | ▶ | sub _elements { return( shift->children->filter(sub{ $_->isElementNode }) ); } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
_elements: not called CC=1 SCAR=6.9
| |||||||||||
| 69 | |||||||||||
| 70 | sub _element_method | ||||||||||
| 71 | 0 | ▶ | { | ||||||||
|
Subroutine
_element_method: not called CC=2 SCAR=17.9
| |||||||||||
| 72 | 0 | my $self = shift( @_ ); | |||||||||
| 73 | 0 | my $meth = shift( @_ ); | |||||||||
| 74 | 0 | require HTML::Object::DOM::Element; | |||||||||
| 75 | 0 | my $code = HTML::Object::DOM::Element->can( $meth ); | |||||||||
| 76 | 0 | ▶ | return( $self->error( "Unknown method \"$meth\" in HTML::Object::DOM::Element" ) ) if( !$code ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 77 | 0 | return( $self->$code( @_ ) ); | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | 2 | 1; | |||||||||
| 81 | # NOTE: POD | ||||||||||
| 82 | __END__ | ||||||||||