Skip to content

Commit 8e27afd

Browse files
committed
properly handle font: shorthands. close #25.
1 parent d3ef1a8 commit 8e27afd

File tree

6 files changed

+37
-3
lines changed

6 files changed

+37
-3
lines changed

dist/dropcss.cjs.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,14 @@ function dropFontFaces(css, shouldDrop) {
879879
}
880880
}
881881

882+
var RE3 = /font:([^;!}]+)/gm;
883+
884+
while (m = RE3.exec(css)) {
885+
m[1].trim().split(",").forEach(function (a) {
886+
used.add(a.trim().match(/\s*['"]?([\w- ]+)['"]?$/)[1]);
887+
});
888+
}
889+
882890
return removeBackwards(css, defs, used, shouldDrop, '@font-face ');
883891
}
884892

dist/dropcss.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,14 @@
883883
}
884884
}
885885

886+
var RE3 = /font:([^;!}]+)/gm;
887+
888+
while (m = RE3.exec(css)) {
889+
m[1].trim().split(",").forEach(function (a) {
890+
used.add(a.trim().match(/\s*['"]?([\w- ]+)['"]?$/)[1]);
891+
});
892+
}
893+
886894
return removeBackwards(css, defs, used, shouldDrop, '@font-face ');
887895
}
888896

dist/dropcss.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dropcss.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ function dropFontFaces(css, shouldDrop) {
8989
}
9090
}
9191

92+
let RE3 = /font:([^;!}]+)/gm;
93+
94+
while (m = RE3.exec(css)) {
95+
m[1].trim().split(",").forEach(a => {
96+
used.add(a.trim().match(/\s*['"]?([\w- ]+)['"]?$/)[1]);
97+
});
98+
}
99+
92100
return removeBackwards(css, defs, used, shouldDrop, '@font-face ');
93101
}
94102

test/coverage.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
------------|----------|----------|----------|----------|-------------------|
22
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
33
------------|----------|----------|----------|----------|-------------------|
4-
All files | 96.55 | 89.41 | 98 | 96.43 | |
4+
All files | 96.58 | 89.41 | 98.04 | 96.46 | |
55
css.js | 97.22 | 90.48 | 100 | 97.12 | 133,134,167 |
6-
dropcss.js | 98.33 | 93.48 | 100 | 98.21 | 59,172 |
6+
dropcss.js | 98.39 | 93.48 | 100 | 98.28 | 59,180 |
77
err.js | 50 | 100 | 0 | 50 | 2 |
88
find.js | 99.19 | 95.24 | 100 | 99.18 | 163 |
99
html.js | 97.8 | 92.31 | 100 | 97.7 | 73,117 |

0 commit comments

Comments
 (0)