MCPcopy
hub / github.com/webpack/webpack / scanRuleBody

Function scanRuleBody

lib/css/CssParser.js:586–610  ·  view source on GitHub ↗
(declarations, childRules)

Source from the content-addressed store, hash-verified

584 * @returns {{ hasDirectDecl: boolean, hasNestedBlock: boolean }} scan result
585 */
586const scanRuleBody = (declarations, childRules) => {
587 let hasDirectDecl = Boolean(declarations && declarations.length > 0);
588 let hasNestedBlock = false;
589 if (childRules) {
590 for (const child of childRules) {
591 const t = A.type(child);
592 if (t === NodeType.QualifiedRule) {
593 hasNestedBlock = true;
594 } else if (t === NodeType.AtRule) {
595 const atDecls = A.declarations(child);
596 const atChildRules = A.childRules(child);
597 if (!atDecls && !atChildRules) continue;
598 hasNestedBlock = true;
599 if (
600 !hasDirectDecl &&
601 !isPureBodyAtRule(`@${A.name(child).toLowerCase()}`) &&
602 scanRuleBody(atDecls, atChildRules).hasDirectDecl
603 ) {
604 hasDirectDecl = true;
605 }
606 }
607 }
608 }
609 return { hasDirectDecl, hasNestedBlock };
610};
611
612/**
613 * Parses value at rule params.

Callers 1

enterBlockMethod · 0.85

Calls 3

isPureBodyAtRuleFunction · 0.85
nameMethod · 0.80
typeMethod · 0.45

Tested by

no test coverage detected