提交 02752ddb 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

fix(h5): 修复page选择器媒体查询无效问题

上级 e0797029
...@@ -170,8 +170,6 @@ if (process.env.UNI_USING_V3) { ...@@ -170,8 +170,6 @@ if (process.env.UNI_USING_V3) {
if (process.env.UNI_PLATFORM === 'h5') { if (process.env.UNI_PLATFORM === 'h5') {
// Transform CSS AST here // Transform CSS AST here
const bgDecls = []
root.walkRules(rule => { root.walkRules(rule => {
let hasPage = false let hasPage = false
// Transform each rule here // Transform each rule here
...@@ -197,6 +195,7 @@ if (process.env.UNI_USING_V3) { ...@@ -197,6 +195,7 @@ if (process.env.UNI_USING_V3) {
) )
}) })
} }
const bgDecls = []
// handle upx unit // handle upx unit
rule.walkDecls(decl => { rule.walkDecls(decl => {
if (hasPage) { if (hasPage) {
...@@ -207,6 +206,15 @@ if (process.env.UNI_USING_V3) { ...@@ -207,6 +206,15 @@ if (process.env.UNI_USING_V3) {
// Transform each property declaration here // Transform each property declaration here
decl.value = tranformValue(decl.value, opts) 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 => { root.walkAtRules(rule => {
...@@ -214,14 +222,6 @@ if (process.env.UNI_USING_V3) { ...@@ -214,14 +222,6 @@ if (process.env.UNI_USING_V3) {
rule.params = tranformValue(rule.params, opts) 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 { } else {
root.walkRules(rule => { root.walkRules(rule => {
const selectors = transformSelector(rule.selectors.join(','), function (selectors) { const selectors = transformSelector(rule.selectors.join(','), function (selectors) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册