Subject: | Implicitly universal pseudo-selectors handled incorrectly |
CSS3 allows for pseudoselectors to be implicitly universal. That is, the selector ":focus" on its own is equivalent to writing "*:focus". See [1].
The regex on line 285 in CSS::Inliner r3674 [2] doesn't catch this, passing it on to HTML::Query, which proceeds to give a warning.
Attached is a test-case illustrating the problem, and a patch that fixes it.
[1]: http://www.w3.org/TR/selectors/#universal-selector
[2]: https://metacpan.org/source/KAMELKEV/CSS-Inliner-3674/lib/CSS/Inliner.pm#L284
Subject: | css-inliner-implicitly-universal.patch |
diff --git lib/CSS/Inliner.pm lib/CSS/Inliner.pm
index 1500b02..03ef17e 100644
--- lib/CSS/Inliner.pm
+++ lib/CSS/Inliner.pm
@@ -282,7 +282,7 @@ sub inlinify {
my $properties = $$entry{properties};
#skip over psuedo selectors, they are not mappable the same
- if ($selector =~ /[\w\*]:(?:(active|focus|hover|link|visited|after|before|selection|target|first-line|first-letter|first-child|first-child))\b/io) {
+ if ($selector =~ /(?:^|[\s\w\*]):(?:(active|focus|hover|link|visited|after|before|selection|target|first-line|first-letter|first-child|first-child))\b/io) {
$self->_report_warning({ info => "The pseudo-class ':$1' cannot be supported inline" });
next;
}
Subject: | example.pl |
#!/usr/bin/env perl
use strict;
use warnings;
use CSS::Inliner;
my $html = <<HTML;
<html>
<head>
<style type="text/css">
:focus { }
</style>
</head>
<body><span>Hello.</span></body>
</html>
HTML
my $inliner = CSS::Inliner->new();
$inliner->read({ html => $html });
print $inliner->inlinify();
use Data::Dumper; print Dumper($inliner->content_warnings);