CSS-Tiny-Style
view release on metacpan or search on metacpan
lib/CSS/Tiny/Style.pm view on Meta::CPAN
my $self = shift;
my $element = shift;
my $style = $element->attr('style');
$style = $style eq "" ? $self->stringify : (join ";", ($style, $self->stringify));
#$style =~ s/^;//; # why why why?
$element->attr('style', $style)
}
###########################################################################################################
# from CSS spec at http://www.w3.org/TR/CSS21/cascade.html#specificity
###########################################################################################################
# A selector's specificity is calculated as follows:
#
# * count the number of ID attributes in the selector (= a)
# * count the number of other attributes and pseudo-classes in the selector (= b)
# * count the number of element names in the selector (= c)
# * ignore pseudo-elements.
#
# Concatenating the three numbers a-b-c (in a number system with a large base) gives the specificity.
#
lib/CSS/Tiny/Style.pm view on Meta::CPAN
selarr is an alias for selector_array
=head2 Specificity
=head3 specificity
my $style = CSS::Tiny::Style->new('h1.menu li.myclass');
print $style->specificity # prints 22
Returns the selector's specificity as described in
L<http://www.w3.org/TR/CSS21/cascade.html#specificity>. A base 100 is
used.
=head3 count_tags
my $style = CSS::Tiny::Style->new('h1.menu li.myclass #foo');
print $style->count_tags # prints 2
Return the number of tags in the selector
( run in 0.578 second using v1.01-cache-2.11-cpan-49f99fa48dc )