Skip to content

Commit 8bd118d

Browse files
committed
Merge branch 'master' of github.com:css-modules/postcss-modules
2 parents f3bfc6d + a400e14 commit 8bd118d

File tree

5 files changed

+51
-3
lines changed

5 files changed

+51
-3
lines changed

src/behaviours.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export function getDefaultPlugins({
1616
const scope = modulesScope({ generateScopedName, exportGlobals });
1717

1818
const plugins = {
19-
[behaviours.LOCAL]: [values, localByDefault, extractImports, scope],
20-
[behaviours.GLOBAL]: [values, extractImports, scope],
19+
[behaviours.LOCAL]: [values, localByDefault({ mode: 'local' }), extractImports, scope],
20+
[behaviours.GLOBAL]: [values, localByDefault({ mode: 'global' }), extractImports, scope],
2121
};
2222

2323
return plugins[behaviour];

test/__snapshots__/test.js.snap

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,22 @@ p {
202202
"
203203
`;
204204

205+
exports[`only calls plugins once when it processes :global shorthand selector: plugins once - processes :global shorthand selector - CSS 1`] = `
206+
"/* validator-2-start (globalShorthand.css) *//* validator-1-start (globalShorthand.css) */
207+
.title {
208+
color: red;
209+
}/* validator-1-end (globalShorthand.css) *//* validator-2-end (globalShorthand.css) */
210+
"
211+
`;
212+
213+
exports[`only calls plugins once when it processes :local shorthand selector: plugins once - processes :local shorthand selector - CSS 1`] = `
214+
"/* validator-2-start (localShorthand.css) *//* validator-1-start (localShorthand.css) */
215+
._localShorthand_title {
216+
color: red;
217+
}/* validator-1-end (localShorthand.css) *//* validator-2-end (localShorthand.css) */
218+
"
219+
`;
220+
205221
exports[`only calls plugins once when it processes classes: plugins once - processes classes - CSS 1`] = `
206222
"/* validator-2-start (classes.css) */
207223
@@ -268,6 +284,28 @@ p {
268284

269285
exports[`preserves comments: preserves comments - JSON 1`] = `Object {}`;
270286

287+
exports[`processes :global shorthand selector: processes :global shorthand selector - CSS 1`] = `
288+
".title {
289+
color: red;
290+
}
291+
"
292+
`;
293+
294+
exports[`processes :global shorthand selector: processes :global shorthand selector - JSON 1`] = `Object {}`;
295+
296+
exports[`processes :local shorthand selector: processes :local shorthand selector - CSS 1`] = `
297+
"._localShorthand_title {
298+
color: red;
299+
}
300+
"
301+
`;
302+
303+
exports[`processes :local shorthand selector: processes :local shorthand selector - JSON 1`] = `
304+
Object {
305+
"title": "_localShorthand_title",
306+
}
307+
`;
308+
271309
exports[`processes classes: processes classes - CSS 1`] = `
272310
".page {
273311
padding: 20px;

test/fixtures/in/globalShorthand.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:global .title {
2+
color: red;
3+
}

test/fixtures/in/localShorthand.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:local .title {
2+
color: red;
3+
}

test/test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const cases = {
2424
values: "processes values",
2525
interpolated: "generates scoped name with interpolated string",
2626
global: "allows to make CSS global",
27+
localShorthand: "processes :local shorthand selector",
28+
globalShorthand: "processes :global shorthand selector",
2729
};
2830

2931
function generateScopedName(name, filename) {
@@ -40,7 +42,9 @@ Object.keys(cases).forEach((name) => {
4042
: generateScopedName;
4143

4244
const scopeBehaviour =
43-
name === behaviours.GLOBAL ? behaviours.GLOBAL : behaviours.LOCAL;
45+
name === behaviours.GLOBAL || name === "globalShorthand"
46+
? behaviours.GLOBAL
47+
: behaviours.LOCAL;
4448

4549
it(description, async () => {
4650
const sourceFile = path.join(fixturesPath, "in", `${name}.css`);

0 commit comments

Comments
 (0)