- "5.14"
- "5.12"
- "5.10"
+ - "5.8"
use strict;
use warnings;
- use 5.010001;
+ use 5.008001;
# use Module::Build::Tiny 0.034;
Module::Build::Tiny::Build_PL();
}
}
- # This section was automatically generated by Dist::Zilla::Plugin::ModuleBuild v5.040.
+ # This section was automatically generated by Dist::Zilla::Plugin::ModuleBuild v5.041.
use strict;
use warnings;
"Exporter" => 0,
"List::Util" => 0,
"Scalar::Util" => 0,
- "perl" => "5.010001"
+ "perl" => "5.008001"
},
"test_requires" => {
+ "Encode" => 0,
"JSON::Tiny" => "0.41",
"Test::More" => "0.88"
}
my %fallback_build_requires = (
+ "Encode" => 0,
"JSON::Tiny" => "0.41",
"Test::More" => "0.88"
);
"Dan Book <dbook@cpan.org>"
],
"dynamic_config" : 0,
- "generated_by" : "Dist::Zilla version 5.040, CPAN::Meta::Converter version 2.150005",
+ "generated_by" : "Dist::Zilla version 5.041, CPAN::Meta::Converter version 2.150005",
"license" : [
"artistic_2"
],
"Exporter" : "0",
"List::Util" : "0",
"Scalar::Util" : "0",
- "perl" : "5.010001"
+ "perl" : "5.008001"
}
},
"test" : {
"requires" : {
+ "Encode" : "0",
"JSON::Tiny" : "0.41",
"Test::More" : "0.88"
}
-requires 'perl' => '5.010001';
+requires 'perl' => '5.008001';
requires 'Carp';
requires 'Class::Tiny::Chained';
requires 'Exporter';
requires 'List::Util';
requires 'Scalar::Util';
+test_requires 'Encode';
test_requires 'JSON::Tiny' => '0.41';
test_requires 'Test::More' => '0.88';
sub val {
my $self = shift;
+ my $tag = $self->tag;
+
# "option"
- return $self->{value} // $self->text if (my $tag = $self->tag) eq 'option';
+ return defined $self->{value} ? $self->{value} : $self->text if $tag eq 'option';
# "textarea", "input" or "button"
return $tag eq 'textarea' ? $self->text : $self->{value} if $tag ne 'select';
sub _parse { DOM::Tiny::HTML->new(xml => shift->xml)->parse(shift)->tree }
sub _replace {
- my ($self, $parent, $tree, @nodes) = @_;
- splice @$parent, _offset($parent, $tree), 1, _link($parent, @nodes);
+ my ($self, $parent, $child, @nodes) = @_;
+ splice @$parent, _offset($parent, $child), 1, _link($parent, @nodes);
return $self->parent;
}
# Attributes
elsif ($css =~ /\G$ATTR_RE/gco) {
- push @$last, ['attr', _name($1), _value($2 // '', $3 // $4 // $5, $6)];
+ my $op = defined $2 ? $2 : '';
+ my $value = defined $3 ? $3 : (defined $4 ? $4 : $5);
+ push @$last, ['attr', _name($1), _value($op, $value, $6)];
}
# Pseudo-class (":not" contains more selectors)
return $num if $equation !~ /(?:(-?(?:\d+)?)?(n))?\s*\+?\s*(-?\s*\d+)?\s*$/i;
$num->[0] = defined($1) && $1 ne '' ? $1 : $2 ? 1 : 0;
$num->[0] = -1 if $num->[0] eq '-';
- $num->[1] = $3 // 0;
+ $num->[1] = $3 || 0;
$num->[1] =~ s/\s+//g;
return $num;
}
use List::Util;
use Scalar::Util 'blessed';
+our $VERSION = '0.001';
+
our @EXPORT_OK = ('c');
sub TO_JSON { [@{shift()}] }
}
sub join {
- join $_[1] // '', map {"$_"} @{$_[0]};
+ join +(defined $_[1] ? $_[1] : ''), map {"$_"} @{$_[0]};
}
sub last { shift->[-1] }
use strict;
use warnings;
-use utf8;
use Exporter 'import';
+our $VERSION = '0.001';
+
our @EXPORT_OK = qw(html_unescape xml_escape);
# To generate a new HTML entity table run this command
use Scalar::Util 'weaken';
use Class::Tiny::Chained 'xml', { tree => sub { ['root'] } };
+our $VERSION = '0.001';
+
my $ATTR_RE = qr/
- ([^<>=\s\/]+|\/) # Key
+ ([^<>=\s\/]+|\/) # Key
(?:
\s*=\s*
(?s:(["'])(.*?)\g{-2}|([^>\s]*)) # Value
# Attributes
my (%attrs, $closing);
while ($attr =~ /$ATTR_RE/go) {
- my ($key, $value) = ($xml ? $1 : lc $1, $3 // $4);
+ my ($key, $value) = ($xml ? $1 : lc $1, defined $3 ? $3 : $4);
# Empty tag
++$closing and next if $key eq '/';
is $dom->at('[test2=""]')->tag, 'div', 'right tag';
is $dom->at('[test3=""]'), undef, 'no result';
-# Multi-line in attribute
-$dom = DOM::Tiny->new(qq{<div test="line1\nline2" />});
-is $dom->at('div')->attr->{test}, "line1\nline2", 'multi-line attribute';
+# Multi-line attribute
+$dom = DOM::Tiny->new(qq{<div class="line1\nline2" />});
+is $dom->at('div')->attr->{class}, "line1\nline2", 'multi-line attribute value';
+is $dom->at('.line1')->tag, 'div', 'right tag';
+is $dom->at('.line2')->tag, 'div', 'right tag';
+is $dom->at('.line3'), undef, 'no result';
# Whitespaces before closing bracket
$dom = DOM::Tiny->new('<div >content</div>');