Fix nested parens bug (#39)
This commit is contained in:
parent
ee6ef81cf3
commit
7334a550d8
4 changed files with 12 additions and 5 deletions
7
examples/snowpack/package-lock.json
generated
7
examples/snowpack/package-lock.json
generated
|
@ -1010,6 +1010,7 @@
|
||||||
"postcss": "^8.2.8",
|
"postcss": "^8.2.8",
|
||||||
"react": "^17.0.1",
|
"react": "^17.0.1",
|
||||||
"react-dom": "^17.0.1",
|
"react-dom": "^17.0.1",
|
||||||
|
"rollup": "^2.43.1",
|
||||||
"sass": "^1.32.8",
|
"sass": "^1.32.8",
|
||||||
"snowpack": "^3.1.2",
|
"snowpack": "^3.1.2",
|
||||||
"svelte": "^3.35.0",
|
"svelte": "^3.35.0",
|
||||||
|
@ -4096,9 +4097,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rollup": {
|
"rollup": {
|
||||||
"version": "2.42.3",
|
"version": "2.44.0",
|
||||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.42.3.tgz",
|
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.44.0.tgz",
|
||||||
"integrity": "sha512-JjaT9WaUS5vmjy6xUrnPOskjkQg2cN4WSACNCwbOvBz8VDmbiKVdmTFUoMPRqTud0tsex8Xy9/boLbDW9HKD1w==",
|
"integrity": "sha512-rGSF4pLwvuaH/x4nAS+zP6UNn5YUDWf/TeEU5IoXSZKBbKRNTCI3qMnYXKZgrC0D2KzS2baiOZt1OlqhMu5rnQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"fsevents": "~2.3.1"
|
"fsevents": "~2.3.1"
|
||||||
|
|
|
@ -50,7 +50,13 @@ export function scopeSelectors(selector: string, className: string) {
|
||||||
|
|
||||||
// leave :global() alone!
|
// leave :global() alone!
|
||||||
if (value.startsWith(':global(')) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,6 @@ export default function ({ filename, fileID }: { filename: string; fileID: strin
|
||||||
// 3b. Update <style> attributes
|
// 3b. Update <style> attributes
|
||||||
const styleTypeIndex = styleNodes[n].attributes.findIndex(({ name }: any) => name === 'type');
|
const styleTypeIndex = styleNodes[n].attributes.findIndex(({ name }: any) => name === 'type');
|
||||||
if (styleTypeIndex !== -1) {
|
if (styleTypeIndex !== -1) {
|
||||||
console.log(styleNodes[n].attributes[styleTypeIndex]);
|
|
||||||
styleNodes[n].attributes[styleTypeIndex].value[0].raw = 'text/css';
|
styleNodes[n].attributes[styleTypeIndex].value[0].raw = 'text/css';
|
||||||
styleNodes[n].attributes[styleTypeIndex].value[0].data = 'text/css';
|
styleNodes[n].attributes[styleTypeIndex].value[0].data = 'text/css';
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -16,6 +16,7 @@ const tests = {
|
||||||
'.class *': `.class${className} ${className}`,
|
'.class *': `.class${className} ${className}`,
|
||||||
'.class>*': `.class${className}>${className}`,
|
'.class>*': `.class${className}>${className}`,
|
||||||
'.class :global(*)': `.class${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
|
'.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
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue