Skip to content

Commit 6d6c8b6

Browse files
committed
Add support for HTML
1 parent bf91314 commit 6d6c8b6

File tree

7 files changed

+73
-1
lines changed

7 files changed

+73
-1
lines changed

jest-setup.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const path = require('path');
33
const plugin = require('./');
44
const postcss = require('postcss');
55
const jsx = require('postcss-jsx');
6+
const html = require('postcss-html');
67

78
global.groupTest = function(testGroups) {
89
testGroups.forEach(group => {
@@ -51,10 +52,20 @@ global.runTest = function(input, opts, dirname) {
5152
fs.writeFileSync(expectPath, expectCSS);
5253
}
5354

55+
let syntax;
56+
57+
if (inputExt === 'js') {
58+
syntax = jsx;
59+
}
60+
61+
if (inputExt === 'html') {
62+
syntax = html;
63+
}
64+
5465
return postcss([plugin(opts)])
5566
.process(inputCSS, {
5667
from: inputPath,
57-
syntax: inputExt === 'js' ? jsx : undefined,
68+
syntax,
5869
})
5970
.then(result => {
6071
const actualCSS = result.css;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
<div style="position: absolute;top: 0;display: block;z-index: 2;"></div>
5+
</body>
6+
</html>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
<div style="z-index: 2;top: 0;position: absolute;display: block;"></div>
5+
</body>
6+
</html>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
a {
6+
position: absolute;
7+
top: 0;
8+
display: block;
9+
z-index: 2;
10+
}
11+
</style>
12+
</head>
13+
<body>
14+
</body>
15+
</html>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
a {
6+
z-index: 2;
7+
top: 0;
8+
position: absolute;
9+
display: block;
10+
}
11+
</style>
12+
</head>
13+
<body>
14+
</body>
15+
</html>

lib/properties-order/__tests__/properties-order.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,21 @@ test('Ignore template literals in nested components (styled)', () =>
207207
},
208208
__dirname
209209
));
210+
211+
test('Should sort properties (html, <style> tag)', () =>
212+
runTest(
213+
'properties-style-tag.html',
214+
{
215+
'properties-order': ['position', 'top', 'display', 'z-index'],
216+
},
217+
__dirname
218+
));
219+
220+
test('Should sort properties (html, style attribute)', () =>
221+
runTest(
222+
'properties-style-attribute.html',
223+
{
224+
'properties-order': ['position', 'top', 'display', 'z-index'],
225+
},
226+
__dirname
227+
));

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"jest": "^23.4.1",
3838
"jest-watch-typeahead": "^0.2.1",
3939
"lint-staged": "^8.0.4",
40+
"postcss-html": "^0.36.0",
4041
"postcss-jsx": "^0.36.0",
4142
"postcss-syntax": "^0.36.2",
4243
"prettier": "~1.16.4"

0 commit comments

Comments
 (0)