Skip to content

fix(css): preserve cascade layer order for late icons - #548

Merged
atinux merged 2 commits into
nuxt:mainfrom
sean0407:fix/nuxt-icon-543-preserve-css-layer-order
Oct 24, 2026
Merged

atinux merged 2 commits into
nuxt:mainfrom
sean0407:fix/nuxt-icon-543-preserve-css-layer-order

Conversation

@sean0407

Copy link
Copy Markdown

Summary

  • Append client-mounted icon CSS when cssLayer is configured, preserving the app's existing cascade-layer order.
  • Keep the current first-stylesheet placement for unlayered icon CSS.
  • Add regression coverage for both placement rules.

The reported stylesheet insertion causes a full-document style recalculation for late icons, with a measurable impact on mobile interaction latency.

Fixes #543

Checks

  • npm run test:unit -- --run — 88 passed
  • npm run build — passed
  • npm run typecheck — passed
  • ESLint on changed files — passed
  • git diff --check — passed

@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
npm i https://pkg.pr.new/@nuxt/icon@548

commit: a99745d

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f77fab82-48e1-4a1c-a808-1a815e93e10d
Commits

Reviewing files that changed from the base of the PR and between df7d1a2 and a99745d.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6c1be9c3-b14e-4194-99e4-0239ae3c5ef5
📥 Commits

Reviewing files that changed from the base of the PR and between bf962c4 and df7d1a2.

📒 Files selected for processing: 3
  • src/runtime/components/css.ts
  • src/runtime/components/style-order.ts
  • test/style-order.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

mountCSS now uses insertIconStyle to add generated icon styles. When a CSS layer is configured, the function appends the style to document.head. Otherwise, it inserts the style before the first style element or stylesheet link, or appends it when neither exists. Tests cover both ordering paths.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Severity of issue fixed: Medium

Merge Risk: Minimal · up to df7d1

The change preserves existing unlayered behavior while appending layered icon styles as intended, with no identified merge-blocking risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title names the main change: appending client-mounted icon CSS when cssLayer is set, so late icons keep the cascade layer order. The changeset adds insertIconStyle to style-order.ts, switches css.…
Description check Passed The description states the intent: append icon CSS when cssLayer is configured, keep first-stylesheet placement for unlayered CSS, and add regression tests. It also lists the commands run to verify th…
Linked Issues check Passed Issue #543 requires appending client-mounted icon CSS when cssLayer is configured and retaining first-stylesheet placement otherwise. css.ts now calls insertIconStyle with options.cssLayer. Th…
Out of Scope Changes check Passed The changes are limited to icon style insertion, a focused internal helper, and regression tests for issue #543. No unrelated behavior or files are changed.
Full details: Title check

Explanation

The title names the main change: appending client-mounted icon CSS when cssLayer is set, so late icons keep the cascade layer order. The changeset adds insertIconStyle to style-order.ts, switches css.ts to use it, and adds tests for layered and unlayered placement. The title uses the conventional fix(css) prefix and is specific, 53 characters.

Full details: Description check

Explanation

The description states the intent: append icon CSS when cssLayer is configured, keep first-stylesheet placement for unlayered CSS, and add regression tests. It also lists the commands run to verify the change. It matches the changed files in css.ts, style-order.ts, and style-order.test.ts.

Full details: Linked Issues check

Explanation

Issue #543 requires appending client-mounted icon CSS when cssLayer is configured and retaining first-stylesheet placement otherwise. css.ts now calls insertIconStyle with options.cssLayer. The helper appends layered styles and preserves the previous insertion logic for unlayered styles. test/style-order.test.ts covers both placement rules.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@atinux

atinux commented Oct 24, 2026

Copy link
Copy Markdown
Member

Thank you @sean0407 💚

@atinux
atinux merged commit 95cb1fe into nuxt:main Oct 24, 2026
5 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 24, 2026
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.

Client-mounted icon CSS is inserted before all stylesheets even with cssLayer, causing a full-page restyle (~100 ms+ INP on mobile)

2 participants