Skip to content
Permalink
Browse files

fix: scoped styles are not ignored

  • Loading branch information...
sparanoid committed Jul 24, 2018
1 parent f50b7a7 commit a3576bfbe12e554f9f32c9a82eb53b0217ed3dac
Showing with 38 additions and 1 deletion.
  1. +1 −1 tasks/uncss-inline.js
  2. +16 −0 tests/index3.html
  3. +16 −0 tests/index3.ouput.html
  4. +5 −0 tests/unused/mylib.js
@@ -26,7 +26,7 @@ module.exports = function(grunt) {
var { JSDOM } = jsdom;

grunt.registerMultiTask('uncss_inline', 'Remove unused CSS', function() {
var style_selector = 'style:not([amp-boilerplate])';
var style_selector = 'style:not([amp-boilerplate]):not([scoped])';

var done = this.async();
var options = this.options({
@@ -7,6 +7,7 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="./unused/elements.css">
<script src="./unused/mylib.js"></script>
<style>
p {
color: red;
@@ -21,6 +22,17 @@
<body>
<p>Paragraph</p>

<div>
<style scoped>
p {
color: #f0f;
}
</style>
<p>
Content
</p>
</div>

<svg width="60px" height="52px" viewBox="0 0 60 52" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 50.2 (55047) - http://www.bohemiancoding.com/sketch -->
<title>icon-product-bayesgear</title>
@@ -78,6 +90,10 @@
}
</style>

<script>
Mylib.load();
</script>

</body>


@@ -4,6 +4,7 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="./unused/elements.css">
<script src="./unused/mylib.js"></script>
<style>
p {
color: red;
@@ -30,6 +31,17 @@
<body>
<p>Paragraph</p>

<div>
<style scoped="">
p {
color: #f0f;
}
</style>
<p>
Content
</p>
</div>

<svg width="60px" height="52px" viewBox="0 0 60 52" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 50.2 (55047) - http://www.bohemiancoding.com/sketch -->
<title>icon-product-bayesgear</title>
@@ -63,6 +75,10 @@



<script>
Mylib.load();
</script>




@@ -0,0 +1,5 @@
var Mylib = {
load: function() {
console.log('my lib loaded');
}
}

0 comments on commit a3576bf

Please sign in to comment.
You can’t perform that action at this time.