summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Drew Powers <1369770+drwpow@users.noreply.github.com> 2021-03-30 10:37:04 -0600
committerGravatar GitHub <noreply@github.com> 2021-03-30 10:37:04 -0600
commit7334a550d8e042ae0dc59519149df2b3ad04f058 (patch)
tree1189d03d55a553a0732e1a43865e122a4055f369
parentee6ef81cf38acc357141143319addf39a99d3e19 (diff)
downloadastro-7334a550d8e042ae0dc59519149df2b3ad04f058.tar.gz
astro-7334a550d8e042ae0dc59519149df2b3ad04f058.tar.zst
astro-7334a550d8e042ae0dc59519149df2b3ad04f058.zip
Fix nested parens bug (#39)
-rw-r--r--examples/snowpack/package-lock.json7
-rw-r--r--src/compiler/optimize/postcss-scoped-styles/index.ts8
-rw-r--r--src/compiler/optimize/styles.ts1
-rw-r--r--test/astro-scoped-styles.test.js1
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 <style> attributes
const styleTypeIndex = styleNodes[n].attributes.findIndex(({ name }: any) => name === 'type');
if (styleTypeIndex !== -1) {
- console.log(styleNodes[n].attributes[styleTypeIndex]);
styleNodes[n].attributes[styleTypeIndex].value[0].raw = 'text/css';
styleNodes[n].attributes[styleTypeIndex].value[0].data = 'text/css';
} else {
diff --git a/test/astro-scoped-styles.test.js b/test/astro-scoped-styles.test.js
index d6ae7a02e..18870e6c6 100644
--- a/test/astro-scoped-styles.test.js
+++ b/test/astro-scoped-styles.test.js
@@ -16,6 +16,7 @@ const tests = {
'.class *': `.class${className} ${className}`,
'.class>*': `.class${className}>${className}`,
'.class :global(*)': `.class${className} *`,
+ '.class :global(.nav:not(.is-active))': `.class${className} .nav:not(.is-active)`, // preserve nested parens
'.class:not(.is-active)': `.class${className}:not(.is-active)`, // Note: the :not() selector can NOT contain multiple classes, so this is correct; if this causes issues for some people then it‘s worth a discussion
};