0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

Fix nested parens bug (#39)

This commit is contained in:
Drew Powers 2021-03-30 10:37:04 -06:00 committed by GitHub
parent ee6ef81cf3
commit 7334a550d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 5 deletions

View file

@ -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"

View file

@ -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;
}

View file

@ -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 {

View file

@ -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 its worth a discussion
};