Skip to content

Commit 063918f

Browse files
committed
Handle :xml mode for case sensitivity
1 parent d770cb1 commit 063918f

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

lib/CSS/Stylesheet.rakumod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ multi method load(:ruleset($ast)!) {
119119

120120
multi method load($_) is default { warn .raku }
121121

122-
multi method parse(CSS::Stylesheet:U: $str!, Bool :$lax, Bool :$warn = True, |c) {
123-
self.new(|c).parse($str, :$lax, :$warn);
122+
multi method parse(CSS::Stylesheet:U: $str!, Bool :$lax, Bool :$warn = True, Bool :$xml, |c) {
123+
self.new(|c).parse($str, :$lax, :$warn, :$xml);
124124
}
125-
multi method parse(CSS::Stylesheet:D: Str:D() $str!, Bool :$*lax, Bool :$*warn = True, CSS::Module :$module) {
125+
multi method parse(CSS::Stylesheet:D: Str:D() $str!, Bool :$*lax, Bool :$*warn = True, Bool :$xml, CSS::Module :$module) {
126126
$!module = $_ with $module;
127-
my $actions = $!module.actions.new: :$*lax;
127+
my $actions = $!module.actions.new: :$*lax, :$xml;
128128
given $!module.parse($str, :rule<stylesheet>, :$actions) {
129129
@!warnings.append: $actions.warnings;
130130
if $*warn {

t/stylesheet-basic.t

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use Test;
33
use CSS::Stylesheet;
44
use CSS::Media;
55
use CSS::Units :px;
6-
plan 7;
6+
plan 8;
77

88
my $css = q:to<END>;
99
@charset "utf-8";
@@ -18,10 +18,10 @@ my $css = q:to<END>;
1818
html, body, p, th, td, li, dd, dt {
1919
font: 1em Arial, Helvetica, sans-serif;
2020
}
21-
h1, h2, h3, h4, h5, h6 {
21+
H1, h2, h3, h4, h5, h6 {
2222
font-family: Arial, Helvetica, sans-serif;
2323
}
24-
h1 { font-size: 2em; }
24+
H1 { font-size: 2em; }
2525
h2 { font-size: 1.5em; }
2626
h3 { font-size: 1.2em ; }
2727
h4 { font-size: 1.0em; }
@@ -42,4 +42,7 @@ is $stylesheet.rules[0].Str, 'html, body { background:white; border:0; color:bla
4242
is $stylesheet.rules[1].properties, "font:em Arial, Helvetica, sans-serif;";
4343
is $stylesheet.rules.[3].xpath, '//h1';
4444
is $stylesheet.rules.tail.xpath, "//a[link-pseudo('active', .)]";
45+
$stylesheet = CSS::Stylesheet.parse($css, :$media, :xml);
46+
is $stylesheet.rules.[3].xpath, '//H1', ':xml parse mode';
47+
4548
done-testing();

0 commit comments

Comments
 (0)