4 const getUnitFromValueNode = require("./getUnitFromValueNode");
5 const isStandardSyntaxValue = require("./isStandardSyntaxValue");
6 const isVariable = require("./isVariable");
7 const keywordSets = require("../reference/keywordSets");
8 const postcssValueParser = require("postcss-value-parser");
11 * Get the font-families within a `font` shorthand property value.
13 module.exports = function findAnimationName(
15 ) /*: Array<Object>*/ {
16 const animationNames = [];
18 const valueNodes = postcssValueParser(value);
20 // Handle `inherit`, `initial` and etc
22 valueNodes.nodes.length === 1 &&
23 keywordSets.basicKeywords.has(valueNodes.nodes[0].value.toLowerCase())
25 return [valueNodes.nodes[0]];
28 valueNodes.walk(valueNode => {
29 if (valueNode.type === "function") {
32 if (valueNode.type !== "word") {
36 const valueLowerCase = valueNode.value.toLowerCase();
38 // Ignore non standard syntax
39 if (!isStandardSyntaxValue(valueLowerCase)) {
43 if (isVariable(valueLowerCase)) {
46 // Ignore keywords for other font parts
47 if (keywordSets.animationShorthandKeywords.has(valueLowerCase)) {
50 // Ignore numbers with units
51 const unit = getUnitFromValueNode(valueNode);
52 if (unit || unit === "") {
56 animationNames.push(valueNode);
59 return animationNames;