summaryrefslogtreecommitdiff
path: root/node_modules/csso/lib/replace/property/font.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/csso/lib/replace/property/font.js')
-rw-r--r--node_modules/csso/lib/replace/property/font.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/node_modules/csso/lib/replace/property/font.js b/node_modules/csso/lib/replace/property/font.js
new file mode 100644
index 00000000..38e903a2
--- /dev/null
+++ b/node_modules/csso/lib/replace/property/font.js
@@ -0,0 +1,30 @@
+export default function compressFont(node) {
+ const list = node.children;
+
+ list.forEachRight(function(node, item) {
+ if (node.type === 'Identifier') {
+ if (node.name === 'bold') {
+ item.data = {
+ type: 'Number',
+ loc: node.loc,
+ value: '700'
+ };
+ } else if (node.name === 'normal') {
+ const prev = item.prev;
+
+ if (prev && prev.data.type === 'Operator' && prev.data.value === '/') {
+ this.remove(prev);
+ }
+
+ this.remove(item);
+ }
+ }
+ });
+
+ if (list.isEmpty) {
+ list.insert(list.createItem({
+ type: 'Identifier',
+ name: 'normal'
+ }));
+ }
+};