From 3aabd59de17f52399ca4fc3a9f70da788499b7cc Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 15 Oct 2020 11:52:30 -0400 Subject: [PATCH] build(deps): bump postcss-selector-parser from 6.0.2 to 6.0.4 --- packages/compiler-sfc/package.json | 2 +- packages/compiler-sfc/src/stylePluginScoped.ts | 17 +++++++++++++---- yarn.lock | 12 +++++++++++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/packages/compiler-sfc/package.json b/packages/compiler-sfc/package.json index 28ea1145..ae351528 100644 --- a/packages/compiler-sfc/package.json +++ b/packages/compiler-sfc/package.json @@ -49,7 +49,7 @@ "merge-source-map": "^1.1.0", "postcss": "^7.0.32", "postcss-modules": "^3.2.2", - "postcss-selector-parser": "^6.0.2", + "postcss-selector-parser": "^6.0.4", "source-map": "^0.6.1" }, "devDependencies": { diff --git a/packages/compiler-sfc/src/stylePluginScoped.ts b/packages/compiler-sfc/src/stylePluginScoped.ts index 0c2b02bf..359fdea3 100644 --- a/packages/compiler-sfc/src/stylePluginScoped.ts +++ b/packages/compiler-sfc/src/stylePluginScoped.ts @@ -50,7 +50,11 @@ export default postcss.plugin('vue-scoped', (id: any) => (root: Root) => { if (n.nodes.length) { // .foo ::v-deep(.bar) -> .foo[xxxxxxx] .bar // replace the current node with ::v-deep's inner selector - selector.insertAfter(n, n.nodes[0]) + let last: Selector['nodes'][0] = n + n.nodes[0].each(ss => { + selector.insertAfter(last, ss) + last = ss + }) // insert a space combinator before if it doesn't already have one const prev = selector.at(selector.index(n) - 1) if (!prev || !isSpaceCombinator(prev)) { @@ -82,8 +86,13 @@ export default postcss.plugin('vue-scoped', (id: any) => (root: Root) => { // instead. // ::v-slotted(.foo) -> .foo[xxxxxxx-s] if (value === ':slotted' || value === '::v-slotted') { - rewriteSelector(n.nodes[0] as Selector, true /* slotted */) - selector.insertAfter(n, n.nodes[0]) + rewriteSelector(n.nodes[0], true /* slotted */) + let last: Selector['nodes'][0] = n + n.nodes[0].each(ss => { + selector.insertAfter(last, ss) + last = ss + }) + // selector.insertAfter(n, n.nodes[0]) selector.removeChild(n) // since slotted attribute already scopes the selector there's no // need for the non-slot attribute. @@ -129,7 +138,7 @@ export default postcss.plugin('vue-scoped', (id: any) => (root: Root) => { ) } } - selectors.each(selector => rewriteSelector(selector as Selector)) + selectors.each(selector => rewriteSelector(selector)) }).processSync(node.selector) }) diff --git a/yarn.lock b/yarn.lock index 059ec2ea..af373ddf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5741,6 +5741,16 @@ postcss-selector-parser@^6.0.0, postcss-selector-parser@^6.0.2: indexes-of "^1.0.1" uniq "^1.0.1" +postcss-selector-parser@^6.0.4: + version "6.0.4" + resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.4.tgz#56075a1380a04604c38b063ea7767a129af5c2b3" + integrity sha512-gjMeXBempyInaBqpp8gODmwZ52WaYsVOsfr4L4lDQ7n3ncD6mEyySiDtgzCT+NYC0mmeOLvtsF8iaEf0YT6dBw== + dependencies: + cssesc "^3.0.0" + indexes-of "^1.0.1" + uniq "^1.0.1" + util-deprecate "^1.0.2" + postcss-value-parser@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.1.0.tgz#443f6a20ced6481a2bda4fa8532a6e55d789a2cb" @@ -7455,7 +7465,7 @@ use@^3.1.0: resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== -util-deprecate@^1.0.1, util-deprecate@~1.0.1: +util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=