提交 b1b48332 编写于 作者: fxy060608's avatar fxy060608

feat(cli): support >>> or /deep/ or ::v-deep in selectors (without scoped) #1095

上级 08f8b0fd
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
......@@ -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) {
......
......@@ -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()
})
......
......@@ -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') {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册