From b1b4833211fb9b7f69d36e757783f3e11b2808de Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Tue, 31 Dec 2019 19:48:56 +0800 Subject: [PATCH] feat(cli): support >>> or /deep/ or ::v-deep in selectors (without scoped) #1095 --- .../@vue/component-compiler-utils/MODIFY.md | 3 ++- .../dist/compileStyle.js | 3 +++ .../packages/postcss/index.js | 21 ------------------- .../packages/postcss/index.v3.js | 21 ------------------- 4 files changed, 5 insertions(+), 43 deletions(-) diff --git a/packages/vue-cli-plugin-uni/packages/@vue/component-compiler-utils/MODIFY.md b/packages/vue-cli-plugin-uni/packages/@vue/component-compiler-utils/MODIFY.md index 1dfdd3d33f..8c2eb6cbb8 100644 --- a/packages/vue-cli-plugin-uni/packages/@vue/component-compiler-utils/MODIFY.md +++ b/packages/vue-cli-plugin-uni/packages/@vue/component-compiler-utils/MODIFY.md @@ -1,4 +1,5 @@ dist/compileTemplate dist/parse dist/parseCustomBlocks -dist/stylePlugins/scoped.js \ No newline at end of file +dist/stylePlugins/scoped.js +dist/stylePlugins/remove-scoped.js \ No newline at end of file diff --git a/packages/vue-cli-plugin-uni/packages/@vue/component-compiler-utils/dist/compileStyle.js b/packages/vue-cli-plugin-uni/packages/@vue/component-compiler-utils/dist/compileStyle.js index 065dc11661..adaffdd92f 100644 --- a/packages/vue-cli-plugin-uni/packages/@vue/component-compiler-utils/dist/compileStyle.js +++ b/packages/vue-cli-plugin-uni/packages/@vue/component-compiler-utils/dist/compileStyle.js @@ -7,6 +7,7 @@ const postcss = require('postcss'); const trim_1 = __importDefault(require("./stylePlugins/trim")); const scoped_1 = __importDefault(require("./stylePlugins/scoped")); const styleProcessors_1 = require("./styleProcessors"); +const removeScoped_1 = __importDefault(require("./stylePlugins/remove-scoped")); function compileStyle(options) { return doCompileStyle(Object.assign({}, options, { isAsync: false })); } @@ -27,6 +28,8 @@ function doCompileStyle(options) { } if (scoped) { plugins.push(scoped_1.default(id)); + } else { // fixed by xxxxxx + plugins.push(removeScoped_1.default(id)); } const postCSSOptions = Object.assign({}, postcssOptions, { to: filename, from: filename }); if (map) { diff --git a/packages/vue-cli-plugin-uni/packages/postcss/index.js b/packages/vue-cli-plugin-uni/packages/postcss/index.js index 65494c5a28..0b1300e035 100644 --- a/packages/vue-cli-plugin-uni/packages/postcss/index.js +++ b/packages/vue-cli-plugin-uni/packages/postcss/index.js @@ -212,27 +212,6 @@ if (process.env.UNI_USING_V3) { } else { root.walkRules(rule => { const selectors = transformSelector(rule.selectors.join(','), function (selectors) { - selectors.each((selector) => { - // find the last child node to insert attribute selector - selector.each((n) => { - // ">>>" combinator - // and /deep/ alias for >>>, since >>> doesn't work in SASS - if (n.type === 'combinator' && - (n.value === '>>>' || n.value === - '/deep/')) { - n.value = ' ' - n.spaces.before = n.spaces.after = '' - return false - } - // in newer versions of sass, /deep/ support is also dropped, so add a ::v-deep alias - if (n.type === 'pseudo' && n.value === - '::v-deep') { - n.value = n.spaces.before = n.spaces.after = - '' - return false - } - }) - }) selectors.walkUniversals(node => { node.parent.remove() }) diff --git a/packages/vue-cli-plugin-uni/packages/postcss/index.v3.js b/packages/vue-cli-plugin-uni/packages/postcss/index.v3.js index 5ec3c5b856..484d199819 100644 --- a/packages/vue-cli-plugin-uni/packages/postcss/index.v3.js +++ b/packages/vue-cli-plugin-uni/packages/postcss/index.v3.js @@ -22,27 +22,6 @@ module.exports = postcss.plugin('postcss-uniapp-plugin', function (opts) { // complexSelector => simpleSelectors // "a.b#c" => ["a", ".b", "#c"] transformSelector(complexSelector, simpleSelectors => { - simpleSelectors.each((selector) => { - // find the last child node to insert attribute selector - selector.each((n) => { - // ">>>" combinator - // and /deep/ alias for >>>, since >>> doesn't work in SASS - if (n.type === 'combinator' && - (n.value === '>>>' || n.value === - '/deep/')) { - n.value = ' ' - n.spaces.before = n.spaces.after = '' - return false - } - // in newer versions of sass, /deep/ support is also dropped, so add a ::v-deep alias - if (n.type === 'pseudo' && n.value === - '::v-deep') { - n.value = n.spaces.before = n.spaces.after = - '' - return false - } - }) - }) // only process type selector, leave alone class & id selectors return simpleSelectors.walkTags(tag => { if (tag.value === 'page') { -- GitLab