Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion selectivizr.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ References:

// Stylesheet parsing regexp's
var RE_COMMENT = /(\/\*[^*]*\*+([^\/][^*]*\*+)*\/)\s*?/g;
var RE_IMPORT = /@import\s*(?:(?:(?:url\(\s*(['"]?)(.*)\1)\s*\))|(?:(['"])(.*)\3))\s*([^;]*);/g;
var RE_IMPORT = /@import\s*(?:(?:(?:url\(\s*(['"]?)([^;]*)\1)\s*\))|(?:(['"])([^;]*)\3))\s*([^;]*);/g;
var RE_ASSET_URL = /(behavior\s*?:\s*)?\burl\(\s*(["']?)(?!data:)([^"')]+)\2\s*\)/g;
var RE_PSEUDO_STRUCTURAL = /^:(empty|(first|last|only|nth(-last)?)-(child|of-type))$/;
var RE_PSEUDO_ELEMENTS = /:(:first-(?:line|letter))/g;
Expand Down
2 changes: 1 addition & 1 deletion tests/master/css/import-print.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* if @media type filtering doesn't work we want this test to fail */

tr#import-print {
background: #c00;
background: #0c0;
}

24 changes: 18 additions & 6 deletions tests/master/css/master.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,25 @@
@import url("import-print.css") print;
@import url("import-screen.css") screen;

#import-print {
background: #0c0;
}
/* When parsing @import of minified CSS, ensure the Regex isn't too greedy */
@import url("min-import-url-quoted-double.css");.minified{background:url("css/nested/test.png");}
@import url('min-import-url-quoted-single.css');.minified{background:url("css/nested/test.png");}
@import url(min-import-url-unquoted.css);.minified{background:url("css/nested/test.png");}
@import "min-import-quoted-double.css";.minified{background:url("css/nested/test.png");}
@import "min-import-quoted-single.css";.minified{background:url("css/nested/test.png");}
@import url("nested/min-import-url-relative-path.css");.minified{background:url("css/nested/test.png");}
/*
* The following urls will be specific to your own server configuration and will fail
* if used "out of the box". To test root-relative and fully qualifed url's you will
* need to adjust the paths below:
*/

#import-screen {
background: #c00;
}
@import url("/selectivizr-git/tests/master/css/min-import-url-root-relative-path.css");.minified{background:url("css/nested/test.png");}
@import url("http://iis/selectivizr-git/tests/master/css/min-import-url-fully-qualified-path.css");.minified{background:url("css/nested/test.png");}
@import url("//iis/selectivizr-git/tests/master/css/min-import-url-protocol-relative-path.css");.minified{background:url("css/nested/test.png");}

@import url("min-import-print.css") print;.minified{background:url("css/nested/test.png");}
@import url("min-import-screen.css") screen;.minified{background:url("css/nested/test.png");}

body {
padding: 10px;
Expand Down
6 changes: 6 additions & 0 deletions tests/master/css/min-import-print.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* if @media type filtering doesn't work we want this test to fail */

tr#min-import-print {
background: #0c0;
}

1 change: 1 addition & 0 deletions tests/master/css/min-import-quoted-double.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#min-import-quoted-double { background-color: #0c0 }
1 change: 1 addition & 0 deletions tests/master/css/min-import-quoted-single.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#min-import-quoted-single { background-color: #0c0 }
4 changes: 4 additions & 0 deletions tests/master/css/min-import-screen.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tr#min-import-screen {
background: #0c0;
}

1 change: 1 addition & 0 deletions tests/master/css/min-import-url-fully-qualified-path.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#min-import-url-fully-qualfied { background-color: #0c0 }
3 changes: 3 additions & 0 deletions tests/master/css/min-import-url-protocol-relative-path.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#min-import-url-protocol-relative {
background: #0c0;
}
1 change: 1 addition & 0 deletions tests/master/css/min-import-url-quoted-double.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#min-import-url-quoted-double { background-color: #0c0 }
1 change: 1 addition & 0 deletions tests/master/css/min-import-url-quoted-single.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#min-import-url-quoted-single { background-color: #0c0 }
1 change: 1 addition & 0 deletions tests/master/css/min-import-url-root-relative-path.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#min-import-url-root-relative { background-color: #0c0 }
1 change: 1 addition & 0 deletions tests/master/css/min-import-url-unquoted.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#min-import-url-unquoted { background-color: #0c0 }
1 change: 1 addition & 0 deletions tests/master/css/nested/min-import-url-relative-path.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#min-import-url-relative { background-image: url("test.png") }
50 changes: 49 additions & 1 deletion tests/master/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,54 @@ <h3>@import syntax tests</h3>
</tr>
</table>

<h3>Minified @import syntax tests</h3>
<table border="1" width="100%">
<tr id="min-import-url-quoted-double">
<td>@import url("...")</td>
<td>Testing @import rule with url wrapped in double quotes and prefixed with the url() qualifier
</tr>
<tr id="min-import-url-quoted-single">
<td>@import url('...')</td>
<td>Testing @import rule with url wrapped in single quotes and prefixed with the url() qualifier
</tr>
<tr id="min-import-url-unquoted">
<td>@import url(...)</td>
<td>Testing @import rule with url without quotes and prefixed with the url() qualifier
</tr>
<tr id="min-import-quoted-double">
<td>@import "..."</td>
<td>Testing @import rule with url wrapped in double quotes without the url() qualifier
</tr>
<tr id="min-import-quoted-single">
<td>@import '...'</td>
<td>Testing @import rule with url wrapped in single quotes without the url() qualifier
</tr>
<tr id="min-import-url-relative">
<td>@import url("../file.css")</td>
<td>Testing @import rule with a relative path
</tr>
<tr id="min-import-url-root-relative">
<td>@import url("/path/file.css")</td>
<td>Testing @import rule with a root-relative path (see note in 'master.css')
</tr>
<tr id="min-import-url-fully-qualfied">
<td>@import url("http://domain/path/file.css")</td>
<td>Testing @import rule with a fully qualified path (see note in 'master.css')
</tr>
<tr id="min-import-url-protocol-relative">
<td>@import url("//domain/path/file.css")</td>
<td>Testing @import rule with a protocol relative path
</tr>
<tr id="min-import-print">
<td>@import url("...") print</td>
<td>Testing @import rule with a print media type
</tr>
<tr id="min-import-screen">
<td>@import url("...") screen</td>
<td>Testing @import rule with a screen media type
</tr>
</table>

<h3>url syntax tests</h3>
<table border="1" width="100%">
<tr id="url-quoted-double">
Expand Down Expand Up @@ -359,4 +407,4 @@ <h3>HTML5 element tests</h3>
</div>

</body>
</html>
</html>