MCPcopy Create free account
hub / github.com/webstudio-is/webstudio / leave

Function leave

packages/css-data/src/parse-css.ts:751–960  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

749 }
750 },
751 leave(node) {
752 if (node.type === "Atrule") {
753 atruleStack.pop();
754 } else if (node.type === "Rule") {
755 currentRule = undefined;
756 }
757
758 // Process declarations
759 if (
760 node.type !== "Declaration" ||
761 !currentRule ||
762 currentRule.prelude.type === undefined
763 ) {
764 return;
765 }
766
767 // All enclosing at-rules must be @media — reject @supports, @keyframes, etc.
768 if (atruleStack.some((atrule) => atrule.name !== "media")) {
769 return;
770 }
771
772 let breakpoint: undefined | string;
773 let invalidBreakpoint = false;
774
775 // Collect and flatten all enclosing @media preludes
776 const flattenedParts: string[] = [];
777 for (const atrule of atruleStack) {
778 if (atrule.prelude?.type === "AtrulePrelude") {
779 let hasNonPxWidthUnit = false;
780 let hasPrintMedia = false;
781 let currentFeatureName: string | undefined;
782 csstree.walk(atrule.prelude, {
783 enter: (node) => {
784 if (node.type === "MediaQuery") {
785 // Mutates AST in-place to normalize media type for breakpoint string generation;
786 // the AST is discarded after parseCss returns so this is safe.
787 if (node.mediaType === "screen" || node.mediaType === "all") {
788 node.mediaType = null;
789 }
790 if (node.mediaType === "print") {
791 hasPrintMedia = true;
792 }
793 }
794 if (node.type === "Feature") {
795 currentFeatureName = node.name;
796 }
797 // Only reject non-px units on width features (min-width, max-width)
798 if (
799 node.type === "Dimension" &&
800 node.unit !== "px" &&
801 (currentFeatureName === "min-width" ||
802 currentFeatureName === "max-width")
803 ) {
804 hasNonPxWidthUnit = true;
805 }
806 },
807 leave: (node) => {
808 if (node.type === "Feature") {

Callers

nothing calls this directly

Calls 8

parseCssValueFunction · 0.90
normalizePropertyFunction · 0.85
getRawDeclarationValueFunction · 0.85
hasMethod · 0.80
valuesMethod · 0.45

Tested by

no test coverage detected