Skip to content

refactor(mp-alipay): drop page rules left with comments only - #6074

Merged
chouchouji merged 1 commit into
uni-app-vue3-devfrom
fix-alipay-page-background-css-vars
Sep 20, 2026
Merged

chouchouji merged 1 commit into
uni-app-vue3-devfrom
fix-alipay-page-background-css-vars

Conversation

@chouchouji

Copy link
Copy Markdown
Member

After moving CSS variables and background declarations to :root, a page rule containing only comments was kept, leaving an empty rule plus a comment that no longer describes anything in it. Remove such rules as well, while still keeping rules that have remaining declarations or nested rules.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is small, targeted, and the updated test suite directly verifies the new behavior without introducing observable regressions.

Pull request overview

This PR refines the mp-alipay PostCSS page-background adaptation so that it also removes page { ... } rules that become empty after moving declarations, even if they still contain only comments—preventing leftover “comment-only” rules that no longer serve a purpose.

Changes:

  • Add isRemovableRule() to treat comment-only rules as removable after declarations are moved.
  • Update the cleanup condition in createBackgroundRule() to remove rules with no nodes or only comment nodes.
  • Adjust the unit test to assert the comment-only page rule is removed, leaving only the generated :root rule.
File summaries
File Description
packages/uni-cli-shared/src/postcss/plugins/alipayPageBackground.ts Removes original page rules when they are empty or contain only comments after background/CSS var extraction.
packages/uni-cli-shared/tests/uniapp.spec.ts Updates the test expectation to validate removal of comment-only page rules.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Sep 17, 2026

Copy link
Copy Markdown

Size report

Path Size
packages/size-check/dist/size-check.es.js 53.16 KB (0%)
packages/size-check/dist/style.css 2.83 KB (0%)
packages/uni-app/dist/uni-app.es.js 2.41 KB (0%)
packages/uni-h5-vue/dist/vue.runtime.esm.js 76.48 KB (0%)
packages/uni-mp-vue/dist/vue.runtime.esm.js 44.12 KB (0%)
packages/uni-mp-alipay/dist/uni.api.esm.js 16.29 KB (0%)
packages/uni-mp-alipay/dist/uni.mp.esm.js 9.47 KB (0%)
packages/uni-mp-baidu/dist/uni.api.esm.js 12.11 KB (0%)
packages/uni-mp-baidu/dist/uni.mp.esm.js 10.37 KB (0%)
packages/uni-mp-qq/dist/uni.api.esm.js 11.45 KB (0%)
packages/uni-mp-qq/dist/uni.mp.esm.js 8.44 KB (0%)
packages/uni-mp-toutiao/dist/uni.api.esm.js 11.54 KB (0%)
packages/uni-mp-toutiao/dist/uni.mp.esm.js 10.05 KB (0%)
packages/uni-mp-weixin/dist/uni.api.esm.js 12.55 KB (0%)
packages/uni-mp-weixin/dist/uni.mp.esm.js 9 KB (0%)
packages/uni-quickapp-webview/dist/uni.api.esm.js 11.4 KB (0%)
packages/uni-quickapp-webview/dist/uni.mp.esm.js 8.81 KB (0%)

After moving CSS variables and background declarations to :root, a page rule containing only comments was kept, leaving an empty rule plus a comment that no longer describes anything in it. Remove such rules as well, while still keeping rules that have remaining declarations or nested rules.
@chouchouji
chouchouji force-pushed the fix-alipay-page-background-css-vars branch from ac66295 to bd75fbb Compare September 18, 2026 12:43
@chouchouji
chouchouji merged commit 01a2bf6 into uni-app-vue3-dev Sep 20, 2026
4 checks passed
@chouchouji
chouchouji deleted the fix-alipay-page-background-css-vars branch September 20, 2026 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants