source: trip-planner-front/node_modules/postcss-minify-font-values/dist/lib/minify-font.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.9 KB
RevLine 
[6a3a178]1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = _default;
7
8var _postcssValueParser = require("postcss-value-parser");
9
10var _keywords = _interopRequireDefault(require("./keywords"));
11
12var _minifyFamily = _interopRequireDefault(require("./minify-family"));
13
14var _minifyWeight = _interopRequireDefault(require("./minify-weight"));
15
16function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
18function _default(nodes, opts) {
19 let i, max, node, familyStart, family;
20 let hasSize = false;
21
22 for (i = 0, max = nodes.length; i < max; i += 1) {
23 node = nodes[i];
24
25 if (node.type === 'word') {
26 if (hasSize) {
27 continue;
28 }
29
30 const value = node.value.toLowerCase();
31
32 if (value === 'normal' || value === 'inherit' || value === 'initial' || value === 'unset') {
33 familyStart = i;
34 } else if (~_keywords.default.style.indexOf(value) || (0, _postcssValueParser.unit)(value)) {
35 familyStart = i;
36 } else if (~_keywords.default.variant.indexOf(value)) {
37 familyStart = i;
38 } else if (~_keywords.default.weight.indexOf(value)) {
39 node.value = (0, _minifyWeight.default)(value);
40 familyStart = i;
41 } else if (~_keywords.default.stretch.indexOf(value)) {
42 familyStart = i;
43 } else if (~_keywords.default.size.indexOf(value) || (0, _postcssValueParser.unit)(value)) {
44 familyStart = i;
45 hasSize = true;
46 }
47 } else if (node.type === 'function' && nodes[i + 1] && nodes[i + 1].type === 'space') {
48 familyStart = i;
49 } else if (node.type === 'div' && node.value === '/') {
50 familyStart = i + 1;
51 break;
52 }
53 }
54
55 familyStart += 2;
56 family = (0, _minifyFamily.default)(nodes.slice(familyStart), opts);
57 return nodes.slice(0, familyStart).concat(family);
58}
59
60module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.