minifiers: Keep x-bind and blank namespace in SVG minification#14671
minifiers: Keep x-bind and blank namespace in SVG minification#14671bep merged 1 commit intogohugoio:masterfrom
Conversation
Update tdewolff/minify to v2.24.11 and add "" and "x-bind" to KeepNamespaces to prevent Alpine.js directives from being stripped in SVGs. This is a new option in tdewolff/minify v2.24.11, and it is needed to prevent breakage of Alpine.js, and possilby others, directives in SVGs. Fixes gohugoio#14669
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
There was a problem hiding this comment.
Pull request overview
Updates Hugo’s minifier configuration and tests to accommodate new SVG namespace-keeping behavior in tdewolff/minify so Alpine.js-style SVG directives (e.g., x-bind:*) aren’t stripped during minification.
Changes:
- Bump
github.com/tdewolff/minify/v2tov2.24.11(andparse/v2tov2.8.11). - Configure the default SVG minifier to keep namespaces
""and"x-bind". - Add regression tests for SVG minification preserving
x-bind:*and:hrefattributes.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| minifiers/config.go | Sets default svg.Minifier.KeepNamespaces to preserve Alpine/Vue-style directive attributes. |
| minifiers/minifiers_test.go | Adds regression cases for Issue #14669 around SVG attribute preservation. |
| go.mod | Updates tdewolff/minify and tdewolff/parse versions. |
| go.sum | Records new module checksums for the dependency updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Update tdewolff/minify to v2.24.11 and add "" and "x-bind" to KeepNamespaces
to prevent Alpine.js directives from being stripped in SVGs.
This is a new option in tdewolff/minify v2.24.11, and it is needed to prevent breakage of Alpine.js, and possilby others, directives in SVGs.
Fixes #14669