X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FHTML%2FZoom%2FFilterBuilder.pm;h=ed7fef161bacf6fe8d9597eeb860ac8cb55ef136;hb=5dbd334d1950339aea008c46b6d3b37945cd34a7;hp=3c44a7ce8b639211a72c7dbf82dff5a2a4fa6e97;hpb=c84b68f396fb5b0e81dbae8927519b2e06138734;p=catagits%2FHTML-Zoom.git diff --git a/lib/HTML/Zoom/FilterBuilder.pm b/lib/HTML/Zoom/FilterBuilder.pm index 3c44a7c..ed7fef1 100644 --- a/lib/HTML/Zoom/FilterBuilder.pm +++ b/lib/HTML/Zoom/FilterBuilder.pm @@ -42,9 +42,9 @@ sub set_attribute { sub _parse_attribute_args { my $self = shift; - warn "WARNING: Long form arg (name => 'class', value => 'x') is deprecated. This may not do what you originally intended..." + die "Long form arg (name => 'class', value => 'x') is no longer supported" if(@_ == 1 && $_[0]->{'name'} && $_[0]->{'value'}); - + my $opts = ref($_[0]) eq 'HASH' ? $_[0] : {$_[0] => $_[1]}; for (values %{$opts}) { $self->_zconfig->parser->html_escape($_); } return $opts; @@ -71,7 +71,7 @@ sub add_to_attribute { +{ %$evt, raw => undef, raw_attrs => undef, attrs => { %$a, - map {$_ => join(' ', (exists $a->{$_} ? $a->{$_} : ()), $attr->{$_}) } + map {$_ => join(' ', (exists $a->{$_} ? $a->{$_} : ()), $attr->{$_}) } keys %$attr }, @kadd ? (attr_names => [ @{$evt->{attr_names}}, @kadd ]) : () @@ -88,8 +88,9 @@ sub remove_from_attribute { attrs => { %$a, #TODO needs to support multiple removes - map { my $tar = $_; $_ => join ' ', - map {$attr->{$tar} ne $_} split ' ', $a->{$_} } keys %$attr + map { my $tar = $_; $_ => join ' ', + map {$attr->{$tar} ne $_} split ' ', $a->{$_} } + grep {exists $a->{$_}} keys %$attr }, } }; @@ -676,9 +677,9 @@ Similar to add_before, but adds the content to the match. ->select('p') ->prepend_content("Hello ") ->to_html - + ##

Hello World

- + Acceptable values are strings, scalar refs and L objects =head2 append_content @@ -690,7 +691,7 @@ Similar to add_after, but adds the content to the match. ->select('p') ->prepend_content("World") ->to_html - + ##

Hello World

Acceptable values are strings, scalar refs and L objects @@ -727,7 +728,7 @@ pre-generated) } } @list ]); - + Subroutines would be run with $_ localized to result of L (of collected elements), and with said result passed as parameter to subroutine.