Document application modes (development/debug/production) Add global file drop handler, order column normalization, SPA hash fix Serve CDN assets via /_vendor/ URLs instead of merging into bundles Add production minification with license preservation Improve JSON formatting for debugging and production optimization Add CDN asset caching with CSS URL inlining for production builds Add three-mode system (development, debug, production) Update Manifest CLAUDE.md to reflect helper class architecture Refactor Manifest.php into helper classes for better organization Pre-manifest-refactor checkpoint: Add app_mode documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
57 lines
1.4 KiB
JavaScript
Executable File
57 lines
1.4 KiB
JavaScript
Executable File
import { detachNodeFromParent } from '../lib/xast.js';
|
|
|
|
/**
|
|
* @typedef RemoveEmptyTextParams
|
|
* @property {boolean=} text
|
|
* @property {boolean=} tspan
|
|
* @property {boolean=} tref
|
|
*/
|
|
|
|
export const name = 'removeEmptyText';
|
|
export const description = 'removes empty <text> elements';
|
|
|
|
/**
|
|
* Remove empty Text elements.
|
|
*
|
|
* @see https://www.w3.org/TR/SVG11/text.html
|
|
*
|
|
* @example
|
|
* Remove empty text element:
|
|
* <text/>
|
|
*
|
|
* Remove empty tspan element:
|
|
* <tspan/>
|
|
*
|
|
* Remove tref with empty xlink:href attribute:
|
|
* <tref xlink:href=""/>
|
|
*
|
|
* @author Kir Belevich
|
|
*
|
|
* @type {import('../lib/types.js').Plugin<RemoveEmptyTextParams>}
|
|
*/
|
|
export const fn = (root, params) => {
|
|
const { text = true, tspan = true, tref = true } = params;
|
|
return {
|
|
element: {
|
|
enter: (node, parentNode) => {
|
|
// Remove empty text element
|
|
if (text && node.name === 'text' && node.children.length === 0) {
|
|
detachNodeFromParent(node, parentNode);
|
|
}
|
|
// Remove empty tspan element
|
|
if (tspan && node.name === 'tspan' && node.children.length === 0) {
|
|
detachNodeFromParent(node, parentNode);
|
|
}
|
|
// Remove tref with empty xlink:href attribute
|
|
if (
|
|
tref &&
|
|
node.name === 'tref' &&
|
|
node.attributes['xlink:href'] == null
|
|
) {
|
|
detachNodeFromParent(node, parentNode);
|
|
}
|
|
},
|
|
},
|
|
};
|
|
};
|