(prelude)
| 701 | * @returns {ImportPrelude} the recognized prefix parts (any may be undefined) |
| 702 | */ |
| 703 | const parseImportPrelude = (prelude) => { |
| 704 | /** @type {AstNode | undefined} */ |
| 705 | let urlNode; |
| 706 | /** @type {AstNode | undefined} */ |
| 707 | let layerNode; |
| 708 | /** @type {FunctionNode | undefined} */ |
| 709 | let supportsNode; |
| 710 | |
| 711 | for (const cv of prelude) { |
| 712 | const t = A.type(cv); |
| 713 | if (t === NodeType.Whitespace) continue; |
| 714 | |
| 715 | if (!urlNode) { |
| 716 | if (t === NodeType.Url || t === NodeType.String) { |
| 717 | urlNode = cv; |
| 718 | continue; |
| 719 | } |
| 720 | if ( |
| 721 | t === NodeType.Function && |
| 722 | equalsLowerCase(A.unescapedName(cv), "url") |
| 723 | ) { |
| 724 | urlNode = cv; |
| 725 | continue; |
| 726 | } |
| 727 | if (t === NodeType.Ident) { |
| 728 | // CSS Modules: bare ident is a `@value` reference. |
| 729 | urlNode = cv; |
| 730 | continue; |
| 731 | } |
| 732 | break; |
| 733 | } |
| 734 | |
| 735 | if (!layerNode && !supportsNode) { |
| 736 | if (t === NodeType.Ident) { |
| 737 | if (equalsLowerCase(A.unescaped(cv), "layer")) { |
| 738 | layerNode = cv; |
| 739 | continue; |
| 740 | } |
| 741 | } else if ( |
| 742 | t === NodeType.Function && |
| 743 | equalsLowerCase(A.unescapedName(cv), "layer") |
| 744 | ) { |
| 745 | layerNode = cv; |
| 746 | continue; |
| 747 | } |
| 748 | } |
| 749 | |
| 750 | if ( |
| 751 | !supportsNode && |
| 752 | t === NodeType.Function && |
| 753 | equalsLowerCase(A.unescapedName(cv), "supports") |
| 754 | ) { |
| 755 | supportsNode = /** @type {FunctionNode} */ (cv); |
| 756 | continue; |
| 757 | } |
| 758 | |
| 759 | // First media-query token — stop scanning for the prefix. |
| 760 | break; |
no test coverage detected