From 7334a550d8e042ae0dc59519149df2b3ad04f058 Mon Sep 17 00:00:00 2001 From: Drew Powers <1369770+drwpow@users.noreply.github.com> Date: Tue, 30 Mar 2021 10:37:04 -0600 Subject: [PATCH] Fix nested parens bug (#39) --- examples/snowpack/package-lock.json | 7 ++++--- src/compiler/optimize/postcss-scoped-styles/index.ts | 8 +++++++- src/compiler/optimize/styles.ts | 1 - test/astro-scoped-styles.test.js | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/examples/snowpack/package-lock.json b/examples/snowpack/package-lock.json index a52da1c88..ddcb402e2 100644 --- a/examples/snowpack/package-lock.json +++ b/examples/snowpack/package-lock.json @@ -1010,6 +1010,7 @@ "postcss": "^8.2.8", "react": "^17.0.1", "react-dom": "^17.0.1", + "rollup": "^2.43.1", "sass": "^1.32.8", "snowpack": "^3.1.2", "svelte": "^3.35.0", @@ -4096,9 +4097,9 @@ } }, "rollup": { - "version": "2.42.3", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.42.3.tgz", - "integrity": "sha512-JjaT9WaUS5vmjy6xUrnPOskjkQg2cN4WSACNCwbOvBz8VDmbiKVdmTFUoMPRqTud0tsex8Xy9/boLbDW9HKD1w==", + "version": "2.44.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.44.0.tgz", + "integrity": "sha512-rGSF4pLwvuaH/x4nAS+zP6UNn5YUDWf/TeEU5IoXSZKBbKRNTCI3qMnYXKZgrC0D2KzS2baiOZt1OlqhMu5rnQ==", "dev": true, "requires": { "fsevents": "~2.3.1" diff --git a/src/compiler/optimize/postcss-scoped-styles/index.ts b/src/compiler/optimize/postcss-scoped-styles/index.ts index 7949f63b5..a4afd99aa 100644 --- a/src/compiler/optimize/postcss-scoped-styles/index.ts +++ b/src/compiler/optimize/postcss-scoped-styles/index.ts @@ -50,7 +50,13 @@ export function scopeSelectors(selector: string, className: string) { // leave :global() alone! if (value.startsWith(':global(')) { - ss = head + ss.substring(start, end).replace(':global(', '').replace(')', '') + tail; + ss = + head + + ss + .substring(start, end) + .replace(/^:global\(/, '') + .replace(/\)$/, '') + + tail; continue; } diff --git a/src/compiler/optimize/styles.ts b/src/compiler/optimize/styles.ts index 6f0cd9361..fa32445ba 100644 --- a/src/compiler/optimize/styles.ts +++ b/src/compiler/optimize/styles.ts @@ -205,7 +205,6 @@ export default function ({ filename, fileID }: { filename: string; fileID: strin // 3b. Update