postcss-modules-local-by-default
Advanced tools
Comparing version 4.0.3 to 4.0.4
{ | ||
"name": "postcss-modules-local-by-default", | ||
"version": "4.0.3", | ||
"version": "4.0.4", | ||
"description": "A CSS Modules transform to make local scope the default", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -233,2 +233,7 @@ "use strict"; | ||
} | ||
case "nesting": { | ||
if (node.value === "&") { | ||
context.hasLocals = true; | ||
} | ||
} | ||
} | ||
@@ -361,3 +366,3 @@ | ||
const validIdent = | ||
/^-?([a-z\u0080-\uFFFF_]|(\\[^\r\n\f])|-)((\\[^\r\n\f])|[a-z\u0080-\uFFFF_0-9-])*$/i; | ||
/^-?([a-z\u0080-\uFFFF_]|(\\[^\r\n\f])|-(?![0-9]))((\\[^\r\n\f])|[a-z\u0080-\uFFFF_0-9-])*$/i; | ||
@@ -524,6 +529,8 @@ /* | ||
globalKeyframes = false; | ||
} else if (!globalMode) { | ||
if (atRule.params && !localAliasMap.has(atRule.params)) { | ||
atRule.params = ":local(" + atRule.params + ")"; | ||
} | ||
} else if ( | ||
atRule.params && | ||
!globalMode && | ||
!localAliasMap.has(atRule.params) | ||
) { | ||
atRule.params = ":local(" + atRule.params + ")"; | ||
} | ||
@@ -538,2 +545,38 @@ | ||
}); | ||
} else if (/scope$/i.test(atRule.name)) { | ||
atRule.params = atRule.params | ||
.split("to") | ||
.map((item) => { | ||
const selector = item.trim().slice(1, -1).trim(); | ||
const context = localizeNode( | ||
selector, | ||
options.mode, | ||
localAliasMap | ||
); | ||
context.options = options; | ||
context.localAliasMap = localAliasMap; | ||
if (pureMode && context.hasPureGlobals) { | ||
throw atRule.error( | ||
'Selector in at-rule"' + | ||
selector + | ||
'" is not pure ' + | ||
"(pure selectors must contain at least one local class or id)" | ||
); | ||
} | ||
return `(${context.selector})`; | ||
}) | ||
.join(" to "); | ||
atRule.nodes.forEach((declaration) => { | ||
if (declaration.type === "decl") { | ||
localizeDeclaration(declaration, { | ||
localAliasMap, | ||
options: options, | ||
global: globalMode, | ||
}); | ||
} | ||
}); | ||
} else if (atRule.nodes) { | ||
@@ -540,0 +583,0 @@ atRule.nodes.forEach((declaration) => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22433
529