shift->_zconfig->stream_utils->flatten_stream_of_streams(@_)
}
+sub set_attr { shift->set_attribute(@_); }
+
sub set_attribute {
my $self = shift;
my ($name, $value) = $self->_parse_attribute_args(@_);
my $self = shift;
# allow ->add_to_attribute(name => 'value')
# or ->add_to_attribute({ name => 'name', value => 'value' })
+
+ die "WARNING: Long form arg (name => 'class', value => 'x') is deprecated"
+ if(@_ == 1 && $_[0]->{'name'} && $_[0]->{'value'});
my ($name, $value) = @_ > 1 ? @_ : @{$_[0]}{qw(name value)};
return ($name, $self->_zconfig->parser->html_escape($value));
}
die "renamed to add_to_attribute. killing this entirely for 1.0";
}
+sub add_class { shift->add_to_attribute('class',@_) }
+
+sub remove_class { shift->remove_attribute('class',@_) }
+
+sub set_class { shift->set_attribute('class',@_) }
+
+sub set_id { shift->set_attribute('id',@_) }
+
sub add_to_attribute {
my $self = shift;
my ($name, $value) = $self->_parse_attribute_args(@_);
->select('p')
->set_attribute(class=>'paragraph')
->select('div')
- ->set_attribute({name=>'class', value=>'divider'});
-
+ ->set_attribute({class=>'paragraph', name=>'divider'});
Overrides existing values, if such exist. When multiple L</set_attribute>
calls are made against the same or overlapping selection sets, the final
Adds a value to an existing attribute, or creates one if the attribute does not
yet exist. You may call this method with either an Array or HashRef of Args.
-Here's the 'long form' HashRef:
-
$html_zoom
->select('p')
- ->set_attribute(class=>'paragraph')
- ->then
- ->add_to_attribute({name=>'class', value=>'divider'});
-
-And the exact same effect using the 'short form' Array:
-
- $html_zoom
- ->select('p')
- ->set_attribute(class=>'paragraph')
+ ->set_attribute({class => 'paragraph', name => 'test'})
->then
->add_to_attribute(class=>'divider');