-
Notifications
You must be signed in to change notification settings - Fork 206
fix: svg sprite performance and logic #413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
kevinchappell
commented
Nov 13, 2025
- fix: svg icon fetching
- fix: loadResources, multiple tooltip dom
- chore: update tests to work with new sprite logic
remove from dom, store in memory, optimize svgs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors SVG sprite handling from a DOM-injected approach to a bundled, in-memory approach for improved performance and reliability. The sprite is now bundled with the package and parsed in memory rather than fetched and inserted into the DOM. Icons are inlined when used, eliminating the need for xlink:href references.
Key changes include:
- Bundled SVG sprite using Vite's
?rawimport instead of remote fetching - In-memory sprite parsing with DOMParser instead of DOM insertion
- Icon inlining by cloning symbol children directly into SVG elements
- Removed unused
component-cornericon and related styles - Updated test infrastructure to support bundled sprite in Node.js environment
- Fixed multiple tooltip instantiation by creating single global instance
Reviewed Changes
Copilot reviewed 18 out of 25 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/js/common/loaders.js | Refactored sprite loading to use in-memory parsing instead of DOM injection; removed polyfill loading |
| src/lib/js/constants.js | Added bundled sprite import; set default sprite URL to null to use bundled version |
| src/lib/js/common/dom.js | Updated icon rendering to inline SVG content from in-memory sprite instead of using xlink references |
| src/lib/js/editor.js | Moved SmartTooltip instantiation to module level to prevent multiple instances; removed await on resource loading |
| src/lib/js/config.js | Removed polyfills config and isIE check; updated default sprite config to null |
| src/lib/js/common/helpers.mjs | Removed deprecated isIE browser detection function |
| src/lib/js/components/component.js | Removed component-corner icons from component tags |
| tools/test-setup.cjs | Added sprite initialization for test environment using global function |
| tools/svg-loader.mjs | New custom loader to handle SVG imports with ?raw suffix in Node.js tests |
| tools/mocks/sprite-init.mjs | Test initialization module to populate loaded.formeoSprite |
| tools/generate-sprite.js | Added prefixIds SVGO plugin configuration; converted callback to arrow function |
| package.json | Updated test scripts to use experimental loader and import flags; updated contributor email |
| vite.config.lib.mjs | Added dedupe and optimizeDeps config for @draggable/i18n |
| src/lib/sass/components/*.scss | Removed .f-i-component-corner styles and related corner icon references |
| src/lib/icons/*.svg | Optimized/minified multiple icon SVG files; deleted component-corner icon |
| src/lib/icons/formeo-sprite.svg | Regenerated sprite with optimized icons and without component-corner |
| src/demo/js/options/index.js | Commented out i18n location config (now bundled) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
🎉 This PR is included in version 4.2.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |