You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, sometimes it is important to add a selector at the beginning of the css tree. In my case it is the universal seletor (_).
Here an idea to achieve this. This new sub routine _unshift_selector* is just a slightly modified version of the existing add_selector.
Would be nice to see this functionality in the next version of CSS::Simple
Regards, Stefan
=pod
=item unshift_selector( params )
Add a selector and associated properties to the stored rulesets on first place
In the event that this particular ruleset already exists, invoking this method will
simply replace the item. This is important - if you are modifying an existing rule
using this method than the previously existing selectivity will continue to persist.
Delete the selector first if you want to ignore the previous selectivity.
This method requires you to pass in a params hash that contains scalar
css data. For example:
#if we existed already, invoke REPLACE to preserve selectivity
if ($self->check_selector({selector => $$params{selector}})) {
#we probably want to be doing this explicitely
my ($index) = $self->_ordered()->Indices( $$params{selector} );
}
#new element, stick it onto the beginning of the rulesets
else {
#store the properties $self->_ordered()->Unshift($$params{selector},dclone($$params{properties}));
}
return();
}
The text was updated successfully, but these errors were encountered:
s1738berger
changed the title
Add seletor at the beginning of the list
Add seletor at the beginning of the ruleset
Aug 23, 2016
Hi, sometimes it is important to add a selector at the beginning of the css tree. In my case it is the universal seletor (_).
Here an idea to achieve this. This new sub routine _unshift_selector* is just a slightly modified version of the existing add_selector.
Would be nice to see this functionality in the next version of CSS::Simple
Regards, Stefan
=pod
=item unshift_selector( params )
Add a selector and associated properties to the stored rulesets on first place
In the event that this particular ruleset already exists, invoking this method will
simply replace the item. This is important - if you are modifying an existing rule
using this method than the previously existing selectivity will continue to persist.
Delete the selector first if you want to ignore the previous selectivity.
This method requires you to pass in a params hash that contains scalar
css data. For example:
$self->unshift_selector({selector => '.foo', properties => {color => 'red' }});
=cut
sub unshift_selector {
my ($self,$params) = @_;
$self->_check_object();
#if we existed already, invoke REPLACE to preserve selectivity$self->_ordered()->Indices( $ $params{selector} );
if ($self->check_selector({selector => $$params{selector}})) {
#we probably want to be doing this explicitely
my ($index) =
}
$self->_ordered()->Unshift($ $params{selector},dclone($$params{properties}));
#new element, stick it onto the beginning of the rulesets
else {
#store the properties
}
return();
}
The text was updated successfully, but these errors were encountered: