(valueNode, options)
| 12 | node.type === "paren" && node.value === ")"; |
| 13 | |
| 14 | function parseValueNode(valueNode, options) { |
| 15 | const { nodes } = valueNode; |
| 16 | let parenGroup = { |
| 17 | open: null, |
| 18 | close: null, |
| 19 | groups: [], |
| 20 | type: "paren_group", |
| 21 | }; |
| 22 | const parenGroupStack = [parenGroup]; |
| 23 | const rootParenGroup = parenGroup; |
| 24 | let commaGroup = { |
| 25 | groups: [], |
| 26 | type: "comma_group", |
| 27 | }; |
| 28 | const commaGroupStack = [commaGroup]; |
| 29 | |
| 30 | for (let i = 0; i < nodes.length; ++i) { |
| 31 | const node = nodes[i]; |
| 32 | |
| 33 | if ( |
| 34 | options.parser === "scss" && |
| 35 | node.type === "number" && |
| 36 | node.unit === ".." && |
| 37 | node.value.endsWith(".") |
| 38 | ) { |
| 39 | // Work around postcss bug parsing `50...` as `50.` with unit `..` |
| 40 | // Set the unit to `...` to "accidentally" have arbitrary arguments work in the same way that cases where the node already had a unit work. |
| 41 | // For example, 50px... is parsed as `50` with unit `px...` already by postcss-values-parser. |
| 42 | node.value = node.value.slice(0, -1); |
| 43 | node.unit = "..."; |
| 44 | } |
| 45 | |
| 46 | if (node.type === "func" && node.value === "selector") { |
| 47 | const selector = getValueRoot(valueNode).text.slice( |
| 48 | node.group.open.sourceIndex + 1, |
| 49 | node.group.close.sourceIndex, |
| 50 | ); |
| 51 | const parsedSelector = parseSelector(selector); |
| 52 | parsedSelector.sourceIndex = node.group.open.sourceIndex + 1; |
| 53 | parsedSelector.raws ??= {}; |
| 54 | parsedSelector.raws.selector = selector; |
| 55 | node.group.groups = [parsedSelector]; |
| 56 | } |
| 57 | |
| 58 | if (node.type === "func" && node.value === "url") { |
| 59 | const groups = node.group?.groups ?? []; |
| 60 | |
| 61 | // Create a view with any top-level comma groups flattened. |
| 62 | let groupList = []; |
| 63 | for (let i = 0; i < groups.length; i++) { |
| 64 | const group = groups[i]; |
| 65 | if (group.type === "comma_group") { |
| 66 | groupList = [...groupList, ...group.groups]; |
| 67 | } else { |
| 68 | groupList.push(group); |
| 69 | } |
| 70 | } |
| 71 |
no test coverage detected