UNPKG

609 BJavaScriptView Raw
1'use strict';
2
3const keywordSets = require('../reference/keywordSets');
4const valueParser = require('postcss-value-parser');
5
6/**
7 * Check if a word is a font-size value.
8 *
9 * @param {string} word
10 * @returns {boolean}
11 */
12module.exports = function (word) {
13 if (!word) {
14 return false;
15 }
16
17 if (keywordSets.fontSizeKeywords.has(word)) {
18 return true;
19 }
20
21 const numberUnit = valueParser.unit(word);
22
23 if (!numberUnit) {
24 return false;
25 }
26
27 const unit = numberUnit.unit;
28
29 if (unit === '%') {
30 return true;
31 }
32
33 if (keywordSets.lengthUnits.has(unit.toLowerCase())) {
34 return true;
35 }
36
37 return false;
38};