UNPKG

stylelint

Version:
66 lines (52 loc) 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = findAnimationName; var _postcssValueParser = require("postcss-value-parser"); var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser); var _ = require("./"); var _keywordSets = require("../reference/keywordSets"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Get the font-families within a `font` shorthand property value. * * @param {string} value * @return {object} Collection font-family nodes */ function findAnimationName(value) { var animationNames = []; var valueNodes = (0, _postcssValueParser2.default)(value); // Handle `inherit`, `initial` and etc if (valueNodes.nodes.length === 1 && _keywordSets.basicKeywords.has(valueNodes.nodes[0].value.toLowerCase())) { return [valueNodes.nodes[0]]; } valueNodes.walk(function (valueNode) { if (valueNode.type === "function") { return false; } if (valueNode.type !== "word") { return; } var valueLowerCase = valueNode.value.toLowerCase(); // Ignore non standard syntax if (!(0, _.isStandardSyntaxValue)(valueLowerCase)) { return; } // Ignore variables if ((0, _.isVariable)(valueLowerCase)) { return; } // Ignore keywords for other font parts if (_keywordSets.animationShorthandKeywords.has(valueLowerCase)) { return; } // Ignore numbers with units var unit = (0, _.getUnitFromValueNode)(valueNode); if (unit || unit === "") { return; } animationNames.push(valueNode); }); return animationNames; }