Skip to content

Fix Incompatible units errors when sassc compresses Swagger UI CSS - #187

Open
moskvin wants to merge 2 commits into
ruby-grape:masterfrom
moskvin:fix-libsass-css-min-max
Open

moskvin wants to merge 2 commits into
ruby-grape:masterfrom
moskvin:fix-libsass-css-min-max

Conversation

@moskvin

@moskvin moskvin commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Swagger UI 5.33.0 added .swagger-ui section.models .models-scroll{max-height:min(60vh,800px)}. Sprockets apps that compress CSS with sassc (libsass) read min() and max() as Sass functions, so assets:precompile, and any page that renders the asset, fails with:

SassC::SyntaxError: Internal Error: Incompatible units: 'px' and 'vh'.

This has affected every release since 1.0.10.

CSS function names ignore case, but libsass function names don't. So:

  • the vendored swagger-ui.css now uses MIN(60vh,800px), which libsass leaves alone and browsers read the same way;
  • swagger_ui:dist:update upper-cases min(/max( calls on every Swagger UI update, so the scheduled update job doesn't bring the problem back;
  • spec/assets/swagger_ui_css_spec.rb fails if the vendored stylesheet contains a lower-case min()/max() call.

I checked it by compressing the fixed stylesheet with sassc 2.4.0 (style: :compressed). It compiles, and the output keeps MIN(60vh, 800px).

🤖 Generated with Claude Code

moskvin and others added 2 commits November 11, 2026 11:48
Sprockets apps that compress CSS with sassc (libsass) evaluate min() and
max() as Sass functions, so Swagger UI's max-height:min(60vh,800px) fails
assets:precompile with "Incompatible units: 'px' and 'vh'". CSS function
names are case-insensitive but libsass function names are not, so the
vendored stylesheet uses MIN()/MAX(), and swagger_ui:dist:update rewrites
them on every Swagger UI update. A spec guards the vendored stylesheet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the Swagger UI Sass compatibility update.

No open issues 🎉

What changed in this PR

This PR addresses sassc compatibility for Swagger UI CSS in Sprockets applications by preventing Sass from evaluating CSS min() and max() functions with mixed units.

Changes:

  • Updates the asset refresh task to uppercase min() and max() calls while preserving browser behavior.
  • Adds a regression spec that rejects lowercase calls in the vendored stylesheet.
  • Documents the compatibility fix in the changelog.
File Description
spec/​assets/​swagger_ui_css_spec.rb Checks the vendored CSS for lowercase min() and max() calls.
lib/​tasks/​swagger_ui.rake Normalizes function names when importing Swagger UI CSS.
CHANGELOG.md Records the sassc compatibility fix.

Review effort: Balanced

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