DOM/Rule/Style.pm

filter: Statementstmt 33.9% 57 / 168 Branchbran 9.8% 10 / 102 Conditioncond 10.2% 4 / 39 MC/DCmcdc 3.8% 1 / 26 Subroutinesub 83.3% 15 / 18 Podpod 100% 4 / 4 totaltotal 25.4% 91 / 357 CC 68 SCAR 59.8
CC
68
Cov
23%
_selector_matches
653.6
_elem_matches_subsel
586.1
_elem_matches_sel
107.3
CRAP 394.5
↑ Summary DOM/Parser.pm »
1 package CSS::DOM::Rule::Style;
2  
3 22 $VERSION = '0.16';
4  
5 22 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 22 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 22 ▶use CSS::DOM::Exception qw/ SYNTAX_ERR /;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 22 ▶ use CSS::DOM::Rule;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 22 our @ISA = 'CSS::DOM::Rule';
12  
13 22 use constant 1.03 our $_const = {
14 # Don't let this conflict with the superclass.
15 styl => 2,
16 selc => 3,
17 22 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
18 22 ▶{ no strict; delete @{__PACKAGE__.'::'}{_const => keys %{our $_const}} }
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 # overrides:
21 6 ▶sub type { CSS::DOM::Rule::STYLE_RULE }
Subroutine type: called CC=1 SCAR=0.0
Pod documented
22 sub cssText {
23 56 ▶ my $self = shift;
Subroutine cssText: called CC=4 SCAR=13.9
Pod documented
24 56 my $old;
25 56 ▶ if(defined wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined wantarray) 54 2 56
26 54 my $sel = $self->selectorText;
27 54 ▶ length $sel and $sel .= ' ';
Branch: 1 branch
BranchTrueFalseTotal
length $sel and $sel .= ' ' 30 24 54
28 54 $old = "$sel\{ "
29 . $self->[styl]->cssText ." }\n";
30 }
31 56 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 3 53 56
32 3 my $new_rule = $self->_parse(shift);
33 2 @$self[styl,selc] = @$new_rule[styl,selc];
34 }
35 55 $old;
36 };
37  
38  
39 # CSSStyleRule interface:
40  
41 # The selector ($self->[selc]) can be stored several ways, depending on how
42 # deeply we’ve parsed it:
43 #
44 # - a string
45 # - an array of two elements: [ token types, \@tokens ]
46 # - an array of three elements: [ token types, \@tokens, \@tree ]
47 #
48 # Tree format:
49 # * E > F:link + G[foo], E[foo="warning"] DIV.ette E#myid h1[lang|='en']
50 # becomes
51 # [
52 # [ '*' ],
53 # '',
54 # [ 'E' ],
55 # '>',
56 # [ 'F', ':', 'link', undef ],
57 # '+',
58 # [ 'G', 'a', 'foo', undef ], # ‘a’ stands for attr
59 # ],
60 # [
61 # [ 'E', '=', 'foo', 'warning' ],
62 # ''
63 # [ 'DIV', '~', 'class', 'ette' ],
64 # ''
65 # [ 'E', '#', 'myid', undef ],
66 # ''
67 # [ 'h1', '|', 'lang', 'en' ],
68 # ],
69 #
70 # We pad the items above with undef because :foo.bar#baz becomes
71 # [[ undef,
72 # ':', 'foo', undef, # (sets of three)
73 # '~', 'class', 'bar',
74 # '#', 'baz', undef,
75 # ]]
76 sub selectorText { # ~~~ syntax_err
77 85 ▶ my $old = (my $self = shift)->[selc];
Subroutine selectorText: called CC=4 SCAR=13.9
Pod documented
78 # warn "@{$$old[1]}";# if ref $old eq 'ARRAY' and wantarray;
79 85 ▶ $old = join '', @{$$old[1]}
Branch: 1 branch
BranchTrueFalseTotal
if ref $old eq "ARRAY" and defined wantarray 84 1 85
Condition66%2/3
ref $old eq "ARRAY" and defined wantarray
!ll&&!rl&&r
1084
MC/DC50%1/2
ref $old eq "ARRAY" and defined wantarray
ref $old eq "ARRAY" defined wantarray
Truth table66%2/3
A and B
A= ref $old eq "ARRAY"B= defined wantarray
ABresult
0X0
100
111
80 if ref $old eq 'ARRAY' and defined wantarray;
81 85 ▶ $self->[selc] = "".shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 84 85
82 85 $old;
83 }
84  
85 sub _set_selector_tokens {
86 105 ▶ shift->[selc] = \@_;
Subroutine _set_selector_tokens: called CC=1 SCAR=0.0
87 }
88  
89 sub _selector_matches { # ~~~ Does this work with initial space in the selector?
90 0 ▶ my $self = shift;
Subroutine _selector_matches: not called CC=27 SCAR=64.8
91 0 my $elem = shift; # This is assumed to be an HTML::DOM::Element.
92 0 my $pseudo = shift; # pseudo-element
93  
94 # tokenise if necessary
95 0 ▶ unless(ref $self->[selc]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self->[3]) 0 0 0
96 0 require CSS'DOM'Parser;
97 0 $self->[selc] = [ CSS'DOM'tokenise($self->[selc]) ];
98 }
99  
100 # parse selector tokens if necessary
101 0 my $tree;
102 0 ▶ unless($tree = $self->[selc][2]) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tree = $self->[3][2]) 0 0 0
103 0 require CSS::DOM::Util;
104 0 my ($types,@tokens) = ($self->[selc][0], @{ $self->[selc][1] });
105  
106 # ~~~ remove initial whitespace here?
107  
108 0 $self->[selc][2] = $tree = [];
109  
110 # for each sub-selector within the selector (comma-delimited)
111 0 ▶ comma: while($types) {
Branch: 1 branch
BranchTrueFalseTotal
if ($types) 0 0 0
112 0 my @pieces;
113  
114 0 ▶ while($types) {
Branch: 1 branch
BranchTrueFalseTotal
if ($types) 0 0 0
115 0 push @pieces, \my @subsel;
116  
117 # element:
118 0 ▶ if($types =~ s/^i//) {
Branch: 2 branches
BranchTrueFalseTotal
if ($types =~ s/^i//) { } 0 0 0
elsif ($tokens[0] eq '*') { } 0 0 0
119 0 @subsel = lc shift @tokens;
120 }
121 elsif($tokens[0] eq '*') {
122 0 shift @tokens;
123 0 $types =~ s/^.//;
124 0 @subsel = '*';
125 }
126 0 else { @subsel = undef }
127  
128 # suffixes:
129 0 ▶ while($types) {
Branch: 1 branch
BranchTrueFalseTotal
if ($types) 0 0 0
130  
131 # ids:
132 0 ▶ if($types =~ s/^#//) {
Branch: 7 branches
BranchTrueFalseTotal
if ($types =~ s/^#//) { } 0 0 0
elsif ($types =~ /^di/ and $tokens[0] eq '.') { } 0 0 0
elsif ($types =~ s/^(::?)i//) { } 0 0 0
elsif ($types =~ s/^:fi\)//) { } 0 0 0
elsif ($types =~ s/^\[i]//) { } 0 0 0
elsif ($types =~ /^\[id']/ and $tokens[2] eq '=') { } 0 0 0
elsif ($types =~ s/^\[i[~|]']//) { } 0 0 0
133 0 push @subsel, '#', CSS'DOM'Util'unescape( substr shift @tokens, 1 ),
134 undef;
135 }
136  
137 # classes
138 ▶ elsif($types =~ /^di/ && $tokens[0] eq '.') {
Condition0%0/3
$types =~ /^di/ and $tokens[0] eq "."
!ll&&!rl&&r
000
MC/DC0%0/2
$types =~ /^di/ and $tokens[0] eq "."
$types =~ /^di/ $tokens[0] eq "."
Truth table0%0/3
A and B
A= $types =~ /^di/B= $tokens[0] eq "."
ABresult
0X0
100
111
139 0 $types =~ s/^..//; shift @tokens;
140 0 push @subsel, '~', 'class',
141 CSS'DOM'Util'unescape( shift @tokens );
142 }
143  
144 # pseudo-elems and classes
145 elsif($types =~ s/^(::?)i//) {
146 0 push @subsel, $1,lc CSS'DOM'Util'unescape($tokens[length $1]), undef;
147 0 splice @tokens, 0, $+[0];
148 }
149  
150 # :lang() and similar functions
151 elsif($types =~ s/^:fi\)//) {
152 0 push @subsel,
153 ':',
154 lc CSS'DOM'Util'unescape(substr $tokens[1], 0, -1),
155 lc CSS'DOM'Util'unescape($tokens[2]);
156 0 splice @tokens, 0, 4;
157 }
158  
159 # [attr]
160 elsif($types =~ s/^\[i]//) {
161 0 push @subsel, '=', lc CSS'DOM'Util'unescape($tokens[1]), undef;
162 0 splice @tokens, 0, 3;
163 }
164  
165 # [attr='value']
166 ▶ elsif($types =~ /^\[id']/ && $tokens[2] eq '=') {
Condition0%0/3
$types =~ /^\[id']/ and $tokens[2] eq "="
!ll&&!rl&&r
000
MC/DC0%0/2
$types =~ /^\[id']/ and $tokens[2] eq "="
$types =~ /^\[id']/ $tokens[2] eq "="
Truth table0%0/3
A and B
A= $types =~ /^\[id']/B= $tokens[2] eq "="
ABresult
0X0
100
111
167 0 $types =~ s/^.{5}//;
168 0 push @subsel, '=',
169 lc CSS'DOM'Util'unescape($tokens[1]),
170 CSS'DOM'Util'unescape_str($tokens[3]);
171 0 splice @tokens, 0, 5;
172 }
173  
174 # [attr~='value'], [attr|='value']
175 elsif($types =~ s/^\[i[~|]']//) {
176 0 push @subsel, $tokens[2],
177 lc CSS'DOM'Util'unescape($tokens[1]),
178 CSS'DOM'Util'unescape_str($tokens[3]);
179 0 splice @tokens, 0, 5;
180 }
181  
182 0 else { last } # last suffix
183 }
184  
185 # If we reach this point and \@subsel is [ undef ], skip this selector
186 # and move to the next comma
187 0 ▶ if (@subsel == 1 and !defined $subsel[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (@subsel == 1 and not defined $subsel[0]) 0 0 0
Condition0%0/3
@subsel == 1 and not defined $subsel[0]
!ll&&!rl&&r
000
MC/DC0%0/2
@subsel == 1 and not defined $subsel[0]
@subsel == 1 not defined $subsel[0]
Truth table0%0/3
A and not(B)
A= @subsel == 1B= not defined $subsel[0]
ABresult
0X0
100
111
188 22 ▶ no warnings 'regexp';
Subroutine BEGIN: called CC=1 SCAR=0.0
189 0 $types =~ s/^$CSS::DOM::Parser::any_re*,?//o;
190 0 splice @tokens, 0, $+[0];
191 0 next comma;
192 }
193
194 # check for hierarchy indicator (space > +)
195 0 ▶ if($types =~ /^(s?)d/ and $tokens[$+[1]] =~ /([>+])/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($types =~ /^(s?)d/ and $tokens[$+[1]] =~ /([>+])/) { } 0 0 0
Condition0%0/3
$types =~ /^(s?)d/ and $tokens[$+[1]] =~ /([>+])/
!ll&&!rl&&r
000
MC/DC0%0/2
$types =~ /^(s?)d/ and $tokens[$+[1]] =~ /([>+])/
$types =~ /^(s?)d/ $tokens[$+[1]] =~ /([>+])/
Truth table0%0/3
A and B
A= $types =~ /^(s?)d/B= $tokens[$+[1]] =~ /([>+])/
ABresult
0X0
100
111
196 0 push @pieces, $1;
197 0 $types =~ s/^s?d//;
198 0 splice @tokens, $+[0];
199 }
200 0 else { push @pieces, '' }
201  
202 # trailing space
203 0 ▶ $types =~ s/^s// and shift @tokens;
Branch: 1 branch
BranchTrueFalseTotal
$types =~ s/^s// and shift @tokens 0 0 0
204  
205 # check for comma or end
206 0 ▶ if($types =~ s/^(?:,s?|\z)//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($types =~ s/^(?:,s?|\z)//) 0 0 0
207 0 splice @tokens, 0, $+[0];
208 0 push @$tree, \@pieces;
209 0 pop @pieces; # remove redundant ''
210 0 next comma;
211 }
212 }
213 }
214 }
215  
216 #use DDS; Dump $tree if local our $warn = join "", @{$self->[selc][1]}, eq 'ul li span.a';
217  
218 0 my $specificity = '';
219
220 0 comma: for(@$tree) {
221 0 ▶ my $spec = _elem_matches_sel( $elem, $pseudo, $_ ) or next comma;
Branch: 1 branch
BranchTrueFalseTotal
my $spec = _elem_matches_sel($elem, $pseudo, $_) or next comma 0 0 0
222  
223 22 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
224 0 $spec = join '', map chr, @$spec;
225 0 ▶ $spec gt $specificity and $specificity = $spec;
Branch: 1 branch
BranchTrueFalseTotal
$spec gt $specificity and $specificity = $spec 0 0 0
226 }
227  
228 #warn join("", @{$self->[selc][1]}), " ", join ',', map ord, split//,$specificity;
229 0 ▶ return $specificity || ();
Condition0%0/3
$specificity || ()
l!l&&r!l&&!r
000
MC/DC0%0/2
$specificity || ()
$specificity ()
Truth table0%0/3
A || B
A= $specificityB= ()
ABresult
1X1
011
000
230 }
231  
232 sub _elem_matches_sel {
233 0 ▶ my ($elem, $pseudo, $subsels) = @_;
Subroutine _elem_matches_sel: not called CC=11 SCAR=46.8
234  
235 #warn $elem if our $warn;
236 0 ▶ my $spec = _elem_matches_subsel( $elem, $pseudo, $$subsels[-1] )or return;
Branch: 1 branch
BranchTrueFalseTotal
my $spec = _elem_matches_subsel($elem, $pseudo, $subsels->[-1]) or return 0 0 0
237
238 0 ▶ subsel: for(my $i = $#$subsels-1; $i>=0; $i-=2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= 0) 0 0 0
239 0 my $combinator = $$subsels[$i];
240 0 my $next_sel = $$subsels[$i-1];
241  
242 # space between subselectors (ancestor)
243 0 ▶ if(!$combinator) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $combinator) { } 0 0 0
244 0 my $e = $elem;
245 0 ▶ while($e = $e->parentNode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e = $e->parentNode) 0 0 0
246 0 ▶ last if !$e->can('tagName'); # document
Branch: 1 branch
BranchTrueFalseTotal
unless $e->can("tagName") 0 0 0
247 # ~~~ this might be more efficient if we use parentElement, but
248 # but HTML::DOM doesn’t have that yet.
249  
250 # We have to call _match recursively here with a copy of the selector
251 # to account for cases like A > B C, where B might first match an
252 # ancestor that is not a child of A.
253 0 my $s = _elem_matches_sel( $e, undef, [ @$subsels[0..$i-1] ] );
254 0 ▶ if($s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s) 0 0 0
255 0 for(0..2) {
256 22 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
257 0 $$spec[$_] += $$s[$_];
258 }
259 0 last subsel; # recursion makes the rest of this loop unnecessary
260 }
261 }
262 # If we get here, we’ve run out of ancestors.
263 return
264 0 }
265  
266 # parent/sibling
267 else {
268 0 my $meth = ('previousSibling','parentNode')[$combinator eq '>'];
269 0 $elem = $elem->$meth;
270 0 ▶ last unless $elem->can('tagName'); # ~~~ The note above about effici-
Branch: 1 branch
BranchTrueFalseTotal
unless $elem->can("tagName") 0 0 0
271 # ency applies here, too.
272 0 ▶ my $s = _elem_matches_subsel( $elem, undef, $next_sel ) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $s = _elem_matches_subsel($elem, undef, $next_sel) or return 0 0 0
273 0 for(0..2) {
274 0 $$spec[$_] += $$s[$_];
275 }
276 }
277 }
278  
279 0 return $spec;
280 }
281  
282 sub _elem_matches_subsel {
283 0 ▶ my ($elem, $pseudo, $subsel) = @_;
Subroutine _elem_matches_subsel: not called CC=25 SCAR=63.7
284 0 my @subsel = @$subsel;
285  
286 0 my($ids,$attrs,$tags);
287  
288 # tag
289 0 my $tag = shift @subsel;
290 0 ▶ if(defined $tag and $tag ne '*') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tag and $tag ne "*") 0 0 0
Condition0%0/3
defined $tag and $tag ne "*"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $tag and $tag ne "*"
defined $tag $tag ne "*"
Truth table0%0/3
A and B
A= defined $tagB= $tag ne "*"
ABresult
0X0
100
111
291 0 ▶ $tag eq lc $elem->tagName or return;
Branch: 1 branch
BranchTrueFalseTotal
$tag eq lc $elem->tagName or return 0 0 0
292 0 ++$tags
293 }
294  
295 # suffixes
296 0 ▶ while(@subsel) {
Branch: 1 branch
BranchTrueFalseTotal
if (@subsel) 0 0 0
297 0 my($type,$id,$arg) = splice @subsel, 0, 3;
298  
299 0 ▶ if($type eq '#') {
Branch: 6 branches
BranchTrueFalseTotal
if ($type eq '#') { } 0 0 0
elsif ($type eq '~') { } 0 0 0
elsif ($type eq ':' and not $id =~ /^(?:first-l(?:ine|etter)|before|after)\z/) { } 0 0 0
elsif ($type =~ /:/) { } 0 0 0
elsif ($type eq '=') { } 0 0 0
elsif ($type eq '|') { } 0 0 0
300 0 ▶ $id eq $elem->id or return;
Branch: 1 branch
BranchTrueFalseTotal
$id eq $elem->id or return 0 0 0
301 0 ++$ids;
302 }
303 elsif($type eq '~') {
304 0 my $attr = $elem->getAttribute($id);
305 0 ▶ !defined $attr || !length $attr and return;
Branch: 1 branch
BranchTrueFalseTotal
defined $attr and length $attr or return 0 0 0
Condition0%0/3
defined $attr and length $attr
!ll&&!rl&&r
000
MC/DC0%0/2
defined $attr and length $attr
defined $attr length $attr
Truth table0%0/3
A and B
A= defined $attrB= length $attr
ABresult
0X0
100
111
306 0 ▶ $attr =~ /(?:^|[ \t\r\n\f])\Q$arg\E(?:\z|[ \t\r\n\f])/ or return;
Branch: 1 branch
BranchTrueFalseTotal
$attr =~ /(?:^|[ \t\r\n\f])\Q$arg\E(?:\z|[ \t\r\n\f])/ or return 0 0 0
307 0 ++$attrs;
308 }
309 # A single colon is either a CSS 2.1 pseudo-element or a pseudo-class.
310 # Since CSS 3 ps-elems have two colons, we can simply filter out those
311 # pseudo-elems listed in CSS 2.1. The rest are classes.
312 ▶ elsif($type eq ':'
Condition0%0/3
$type eq ":" and not $id =~ /^(?:first-l(?:ine|etter)|before|after)\z/
!ll&&!rl&&r
000
MC/DC0%0/2
$type eq ":" and not $id =~ /^(?:first-l(?:ine|etter)|before|after)\z/
$type eq ":" not $id =~ /^(?:first-l(?:ine|etter)|before|after)\z/
Truth table0%0/3
A and not(B)
A= $type eq ":"B= not $id =~ /^(?:first-l(?:ine|etter)|before|after)\z/
ABresult
0X0
100
111
313 and $id !~ /^(?:first-l(?:ine|etter)|before|after)\z/) { # class
314 # ~~~
315 return
316 0 }
317 elsif($type =~ /:/) { # pseudo-element
318 0 ▶ return unless $pseudo and lc $id eq lc $pseudo;
Branch: 1 branch
BranchTrueFalseTotal
unless $pseudo and lc $id eq lc $pseudo 0 0 0
Condition0%0/3
$pseudo and lc $id eq lc $pseudo
!ll&&!rl&&r
000
MC/DC0%0/2
$pseudo and lc $id eq lc $pseudo
$pseudo lc $id eq lc $pseudo
Truth table0%0/3
A and B
A= $pseudoB= lc $id eq lc $pseudo
ABresult
0X0
100
111
319 }
320 elsif($type eq '=') {
321 0 my $attr = $elem->getAttribute($id);
322 0 ▶ if(defined $arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $arg) { } 0 0 0
323 22 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
324 0 ▶ $attr eq $arg or return;
Branch: 1 branch
BranchTrueFalseTotal
$attr eq $arg or return 0 0 0
325 }
326 0 ▶ else { defined $attr || length $attr or return }
Branch: 1 branch
BranchTrueFalseTotal
defined $attr or length $attr or return 0 0 0
Condition0%0/3
defined $attr or length $attr
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $attr or length $attr
defined $attr length $attr
Truth table0%0/3
A or B
A= defined $attrB= length $attr
ABresult
1X1
011
000
327 0 ++$attrs;
328 }
329 elsif($type eq '|') {
330 0 my $attr = $elem->getAttribute($id);
331 0 ▶ !defined $attr || !length $attr and return;
Branch: 1 branch
BranchTrueFalseTotal
defined $attr and length $attr or return 0 0 0
Condition0%0/3
defined $attr and length $attr
!ll&&!rl&&r
000
MC/DC0%0/2
defined $attr and length $attr
defined $attr length $attr
Truth table0%0/3
A and B
A= defined $attrB= length $attr
ABresult
0X0
100
111
332 0 ▶ $attr =~ /^\Q$arg\E(?:-|\z)/ or return;
Branch: 1 branch
BranchTrueFalseTotal
$attr =~ /^\Q$arg\E(?:-|\z)/ or return 0 0 0
333 0 ++$attrs;
334 }
335 }
336 #warn Dump [$tag,$ids,$attrs,$tags] if our $warn;
337 0 return[$ids,$attrs,$tags];
338 }
339  
340 sub style {
341 114 ▶ $_[0]->[styl] ||= do {
Subroutine style: called CC=2 SCAR=7.0
Pod documented
Condition66%2/3
$_[0][2] ||= do { require CSS::DOM::Style; "CSS::DOM::Style"->new(shift()) }
l!l&&r!l&&!r
91050
MC/DC0%0/2
$_[0][2] ||= do { require CSS::DOM::Style; "CSS::DOM::Style"->new(shift()) }
$_[0][2] do { require CSS::DOM::Style; "CSS::DOM::Style"->new(shift()) }
Truth table66%2/3
A ||= B
A= $_[0][2]B= do { require CSS::DOM::Style; "CSS::DOM::Style"->new(shift()) }
ABresult
1X1
011
000
342 105 require CSS::DOM::Style;
343 105 new CSS::DOM::Style shift
344 };
345 }
346  
347 22 !()__END__()!
348  
349 =head1 NAME
350  
351 CSS::DOM::Rule::Style - CSS style rule class for CSS::DOM
352  
353 =head1 VERSION
354  
355 Version 0.16
356  
357 =head1 SYNOPSIS
358  
359 use CSS::DOM;
360 my $ruleset = CSS::DOM->parse(
361 'p:firstline, h3 { font-weight: bold }'
362 )->cssRules->[0];
363  
364 $ruleset->selectorText; # 'p:firstline, h3'
365 $ruleset->style; # a CSS::DOM::Style object
366 $ruleset->style->fontWeight; # 'bold'
367  
368 =head1 DESCRIPTION
369  
370 This module implements CSS style rules for L<CSS::DOM>. It inherits
371 from
372 L<CSS::DOM::Rule> and implements
373 the CSSStyleRule DOM interface.
374  
375 =head1 METHODS
376  
377 =over 4
378  
379 =item selectorText
380  
381 Returns a string representing the selector(s). Pass an argument to set it.
382  
383 =item style
384  
385 Returns the CSS::DOM::Style object representing the declaration block
386 of this rule.
387  
388 =back
389  
390 =head1 SEE ALSO
391  
392 L<CSS::DOM>
393  
394 L<CSS::DOM::Style>
395  
396 L<CSS::DOM::Rule>
↑ Summary DOM/Parser.pm »