Skip to content

Commit

Permalink
fix(h5): 修复page选择器媒体查询无效问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenyuWang committed Oct 25, 2022
1 parent e079702 commit 02752dd
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/vue-cli-plugin-uni/packages/postcss/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ if (process.env.UNI_USING_V3) {
if (process.env.UNI_PLATFORM === 'h5') {
// Transform CSS AST here

const bgDecls = []

root.walkRules(rule => {
let hasPage = false
// Transform each rule here
Expand All @@ -197,6 +195,7 @@ if (process.env.UNI_USING_V3) {
)
})
}
const bgDecls = []
// handle upx unit
rule.walkDecls(decl => {
if (hasPage) {
Expand All @@ -207,21 +206,22 @@ if (process.env.UNI_USING_V3) {
// Transform each property declaration here
decl.value = tranformValue(decl.value, opts)
})

// handle body background rule
if (bgDecls.length) {
const bodyRule = postcss.rule({
selector: 'body.?%PAGE?%'
})
bgDecls.forEach(decl => bodyRule.append(decl))
rule.after(bodyRule)
}
})

root.walkAtRules(rule => {
if (rule.name === 'media') {
rule.params = tranformValue(rule.params, opts)
}
})

if (bgDecls.length) {
const rule = postcss.rule({
selector: 'body.?%PAGE?%'
})
bgDecls.forEach(decl => rule.append(decl))
root.append(rule)
}
} else {
root.walkRules(rule => {
const selectors = transformSelector(rule.selectors.join(','), function (selectors) {
Expand Down

0 comments on commit 02752dd

Please sign in to comment.